<!doctype html>
<html lang="zh-CN">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <meta name="referrer" content="no-referrer-when-downgrade">
    

    <title>监控中心Zabbix入门  | matrix</title>
    <meta property="og:title" content="监控中心Zabbix入门  - matrix">
    <meta property="og:type" content="article">
        
    <meta property="article:published_time" content='2021-01-16T14:30:24&#43;08:00'>
        
        
    <meta property="article:modified_time" content='2021-01-16T14:30:24&#43;08:00'>
        
    <meta name="Keywords" content="黑客技术，WEB安全，让你听懂每个漏洞成因，明白每个技术原理,博客,项目管理,python,软件架构,公众号,小程序">
    <meta name="description" content="监控中心Zabbix入门 ">
        
    <meta name="author" content="matrix">
    <meta property="og:url" content="https://gitmatrix.gitee.io/post/Linux-%E8%BF%90%E7%BB%B4%E7%AC%94%E8%AE%B0/Zabbix/%E7%9B%91%E6%8E%A7%E4%B8%AD%E5%BF%83Zabbix%E5%85%A5%E9%97%A8/">
    <link rel="shortcut icon" href='/favicon.ico'  type="image/x-icon">

    <link rel="stylesheet" href='/css/normalize.css'>
    <link rel="stylesheet" href='/css/style.css'>
    <script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    
    
    
        <link href="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" rel="stylesheet">
    
    
    
    
        <link rel="stylesheet" href='/css/douban.css'>
    
        <link rel="stylesheet" href='/css/other.css'>
    
</head>


<body>
    <header id="header" class="clearfix">
    <div class="container">
        <div class="col-group">
            <div class="site-name ">
                
                    <a id="logo" href="https://gitmatrix.gitee.io/">
                        matrix
                    </a>
                
                <p class="description">黑客技术，WEB安全，让你听懂每个漏洞成因，明白每个技术原理</p>
            </div>
            <div>
                <nav id="nav-menu" class="clearfix">
                    <a class="current" href="https://gitmatrix.gitee.io/">首页</a>
                    
                    <a  href="https://gitmatrix.gitee.io/archives/" title="归档">归档</a>
                    
                    <a  href="https://gitmatrix.gitee.io/about/" title="关于">关于</a>
                    
                </nav>
            </div>
        </div>
    </div>
</header>

    <div id="body">
        <div class="container">
            <div class="col-group">

                <div class="col-8" id="main">
                    
<div class="res-cons">
    <style type="text/css">
    .post-toc {
        position: fixed;
        width: 200px;
        margin-left: -210px;
        padding: 5px 10px;
        font-family: Athelas, STHeiti, Microsoft Yahei, serif;
        font-size: 12px;
        border: 1px solid rgba(0, 0, 0, .07);
        border-radius: 5px;
        background-color: rgba(255, 255, 255, 0.98);
        background-clip: padding-box;
        -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        word-wrap: break-word;
        white-space: nowrap;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        z-index: 999;
        cursor: pointer;
        max-height: 70%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .post-toc .post-toc-title {
        width: 100%;
        margin: 0 auto;
        font-size: 20px;
        font-weight: 400;
        text-transform: uppercase;
        text-align: center;
    }

    .post-toc .post-toc-content {
        font-size: 15px;
    }

    .post-toc .post-toc-content>nav>ul {
        margin: 10px 0;
    }

    .post-toc .post-toc-content ul {
        padding-left: 20px;
        list-style: square;
        margin: 0.5em;
        line-height: 1.8em;
    }

    .post-toc .post-toc-content ul ul {
        padding-left: 15px;
        display: none;
    }

    @media print,
    screen and (max-width:1057px) {
        .post-toc {
            display: none;
        }
    }
</style>
<div class="post-toc" style="position: absolute; top: 188px;">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
        <nav id="TableOfContents">
  <ul>
    <li><a href="#一监控介绍">一、监控介绍</a>
      <ul>
        <li><a href="#1cacti">1、Cacti</a></li>
        <li><a href="#2nagios">2、Nagios</a></li>
        <li><a href="#3ganglia">3、Ganglia</a></li>
        <li><a href="#4zabbix">4、Zabbix</a></li>
      </ul>
    </li>
    <li><a href="#二监控区别">二、监控区别</a></li>
    <li><a href="#三zabbix-监控介绍">三、Zabbix 监控介绍</a>
      <ul>
        <li><a href="#1zabbix-监控架构">1、Zabbix 监控架构</a></li>
        <li><a href="#3zabbix-优点">3、Zabbix 优点</a></li>
        <li><a href="#4zabbix-缺点">4、Zabbix 缺点</a></li>
        <li><a href="#5zabbix-监控系统监控对象">5、Zabbix 监控系统监控对象</a></li>
        <li><a href="#6zabbix监控方式">6、Zabbix监控方式</a></li>
        <li><a href="#7zabbix-架构">7、Zabbix 架构</a></li>
        <li><a href="#8zabbix-常用术语的含义">8、Zabbix 常用术语的含义</a></li>
      </ul>
    </li>
    <li><a href="#四zabbix-监控系统部署">四、Zabbix 监控系统部署</a>
      <ul>
        <li><a href="#1实验准备">1、实验准备</a></li>
        <li><a href="#2zabbix的安装">2、Zabbix的安装</a></li>
        <li><a href="#3配置-server-端">3、配置 server 端</a></li>
        <li><a href="#4配置-web-gui">4、配置 web GUI</a></li>
        <li><a href="#5浏览器访问并进行初始化设置">5、浏览器访问并进行初始化设置</a></li>
        <li><a href="#6配置-agent-端">6、配置 agent 端</a></li>
        <li><a href="#7监控过程详解">7、监控过程详解</a></li>
      </ul>
    </li>
    <li><a href="#五zabbix-用户参数">五、Zabbix 用户参数</a>
      <ul>
        <li><a href="#1介绍和用法">1、介绍和用法</a></li>
        <li><a href="#2用法展示">2、用法展示</a></li>
        <li><a href="#3用法升级">3、用法升级</a></li>
        <li><a href="#4使用用户参数监控-php-fpm-服务的状态">4、使用用户参数监控 php-fpm 服务的状态</a></li>
      </ul>
    </li>
    <li><a href="#六zabbix-网络发现">六、Zabbix 网络发现</a>
      <ul>
        <li><a href="#1介绍-1">1、介绍</a></li>
        <li><a href="#2发现方式">2、发现方式</a></li>
        <li><a href="#3发现过程">3、发现过程</a></li>
        <li><a href="#4配置网络发现-network-discovery">4、配置网络发现 Network discovery</a></li>
      </ul>
    </li>
    <li><a href="#七zabbix-web-监控">七、Zabbix web 监控</a>
      <ul>
        <li><a href="#1介绍-2">1、介绍</a></li>
        <li><a href="#2创建设置web场景">2、创建设置web场景</a></li>
        <li><a href="#3查看测试">3、查看测试</a></li>
      </ul>
    </li>
    <li><a href="#八zabbix-主动被动-监控">八、Zabbix 主动/被动 监控</a>
      <ul>
        <li><a href="#1介绍-3">1、介绍</a></li>
        <li><a href="#2设置一个通过內建key发送数据的主动监控">2、设置一个通过內建key发送数据的主动监控</a></li>
        <li><a href="#3设置一个通过命令zabbix_sender发送数据的主动监控">3、设置一个通过命令zabbix_sender发送数据的主动监控</a></li>
      </ul>
    </li>
  </ul>
</nav>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var postToc = $(".post-toc");
        if (postToc.length) {
            var leftPos = $("#main").offset().left;
            if(leftPos<220){
                postToc.css({"width":leftPos-10,"margin-left":(0-leftPos)})
            }

            var t = postToc.offset().top - 20,
                a = {
                    start: {
                        position: "absolute",
                        top: t
                    },
                    process: {
                        position: "fixed",
                        top: 20
                    },
                };
            $(window).scroll(function () {
                var e = $(window).scrollTop();
                e < t ? postToc.css(a.start) : postToc.css(a.process)
            })
        }
    })
</script>
    <article class="post">
        <header>
            <h1 class="post-title">监控中心Zabbix入门 </h1>
        </header>
        <date class="post-meta meta-date">
            2021年1月16日
        </date>
        
        <div class="post-meta">
            <span>|</span>
            
            <span class="meta-category"><a href='/categories/%E8%BF%90%E7%BB%B4'>运维</a></span>
            
        </div>
        
        
        <div class="post-meta">
            <span id="busuanzi_container_page_pv">|<span id="busuanzi_value_page_pv"></span><span>
                    阅读</span></span>
        </div>
        
        
        <div class="clear" style="display: none">
            <div class="toc-article">
                <div class="toc-title">文章目录</div>
            </div>
        </div>
        
        <div class="post-content">
            <p>监控中心Zabbix入门</p>
<h2 id="一监控介绍">一、监控介绍</h2>
<ul>
<li>
<p>你用过哪些监控软件？</p>
</li>
<li>
<p>zabbix 和 nagios、cacti、ganglia 有什么区别？</p>
</li>
<li>
<p>zabbix 有那些好处？</p>
</li>
<li>
<p>zabbix 的监控流程是什么？</p>
</li>
<li>
<p>zabbix 常见监控项有那些？</p>
</li>
</ul>
<h3 id="1cacti">1、Cacti</h3>
<p>Cacti 是一套基于 PHP、MySQL、SNMP 及 RRD Tool 开发的监测图形分析工具,Cacti 是使用轮询的方式由主服务器向设备发送数据请求来获取设备上状态数据信息的,如果设备不断增多,这个轮询的过程就非常的耗时,轮询的结果就不能即时的反应设备的状态了。Cacti 监控关注的是对数据的展示,却不关注数据异常后的反馈。如果凌晨 3 点的时候设备的某个数据出现异常,除非监控人员在屏幕前发现这个异常变化,否则是没有任何报警机制能够让我们道出现了异常。</p>
<h3 id="2nagios">2、Nagios</h3>
<ul>
<li>
<p>Nagios 是一款开源的免费网络监控报警服务,能有效监控 Windows、Linux 和 Unix 的主机状态,交换机、路由器和防火墙等网络设置,打印机、网络投影、网络摄像等设备。在系统或服务状态异常时发出邮件或短信报警第一时间通知运维人员,在状态恢复后发出正常的邮件或短信通知。Nagios 有完善的插件功能,可以方便的根据应用服务扩展功能。</p>
</li>
<li>
<p>Nagios 已经可以支持由数万台服务器或上千台网络设备组成的云技术平台的监控,它可以充分发挥自动化运维技术特点在设备和人力资源减少成本。只是 Nagios 无法将多个相同应用集群的数据集合起来,也不能监控到集群中特殊节点的迁移和恢复。</p>
</li>
</ul>
<h3 id="3ganglia">3、Ganglia</h3>
<ul>
<li>
<p>Ganglia 是 UC Berkeley 发起的一个开源集群监视项目,设计用于测量数以千计的节点。Ganglia 的核心包含 gmond、gmetad 以及一个 Web 前端。</p>
</li>
<li>
<p>主要是用来监控系统性能,如:CPU 、内存、硬盘利用率, I/O 负载、网络流量情况等,通过曲线很容易见到每个节点的工作状态,对合理调整、分配系统资源,提高系统整体   性能起到重要作用,目前是监控HADOOP 的官方推荐服务。</p>
</li>
</ul>
<h3 id="4zabbix">4、Zabbix</h3>
<ul>
<li>
<p>Zabbix 是一个基于 WEB 界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix 能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。</p>
</li>
<li>
<p>Zabbix 是由 Alexei Vladishev 创建，目前由 Zabbix SIA 在持续开发和支持。</p>
</li>
<li>
<p>Zabbix 是一个企业级的分布式开源监控方案。</p>
</li>
<li>
<p>Zabbix 是一款能够监控各种网络参数以及服务器健康性和完整性的软件。</p>
</li>
<li>
<p>Zabbix 使用灵活的通知机制，允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。基于已存储的数据，Zabbix提供了出色的报告和数据可视化功能。这些功能使得Zabbix成为容量规划的理想方案。</p>
</li>
<li>
<p>Zabbix 支持主动轮询和被动捕获。</p>
</li>
<li>
<p>Zabbix所有的报告、统计信息和配置参数都可以通过基于Web的前端页面进行访问。基于Web的前端页面可以确保您从任何方面评估您的网络状态和服务器的健康性。</p>
</li>
<li>
<p>Zabbix是免费的。Zabbix是根据GPL通用公共许可证第2版编写和发行的。这意味着它的源代码都是免费发行的，可供公众任意使用, <a href="http://www.zabbix.com/support.php">商业支持</a> 由Zabbix公司提供。</p>
</li>
</ul>
<h2 id="二监控区别">二、监控区别</h2>
<ul>
<li>​    nagios 图形不是特别好，也可以安装图形插件，但是也不怎么好看</li>
<li>​    nagios 一般情况下如果需要图形可以和 cacti 配合使用</li>
<li>​    cacti 的监控是轮询监控,效率低，图形相对 nagios 比较好看</li>
<li>​    zabbix 和 nagios 因为是并发监控，对 cpu 的要求更高</li>
<li>​    zabbix 在性能和功能上都强大很多</li>
<li>​    zabbix 的图形相当漂亮</li>
<li>​    支持多种监控方式 zabbix-agent  snmp 等等</li>
<li>​    支持分布式监控,能监控的 agent 非常多</li>
<li>​    zabbix 有图形的 web 配置界面，配置简洁</li>
<li>​    zabbix 支持自动发现功能</li>
</ul>
<h2 id="三zabbix-监控介绍">三、Zabbix 监控介绍</h2>
<h3 id="1zabbix-监控架构">1、Zabbix 监控架构</h3>
<p>​                                 
        <a data-fancybox="gallery" href="/assets/image-20200408150704319.png">
            <img class="mx-auto" alt="image-20200408150704319" src="/assets/image-20200408150704319.png" />
        </a>
    </p>
<h3 id="3zabbix-优点">3、Zabbix 优点</h3>
<ul>
<li>
<p>开源,无软件成本投入</p>
</li>
<li>
<p>Server 对设备性能要求低</p>
</li>
<li>
<p>支持设备多,自带多种监控模板</p>
</li>
<li>
<p>支持分布式集中管理,有自动发现功能,可以实现自动化监控</p>
</li>
<li>
<p>开放式接口,扩展性强,插件编写容易</p>
</li>
<li>
<p>当监控的 item 比较多服务器队列比较大时可以采用主动状态,被监控客户端主动 从server 端去下载需要监控的 item 然后取数据上传到 server 端。 这种方式对服务器的负载比较小。</p>
</li>
<li>
<p>Api 的支持,方便与其他系统结合</p>
</li>
</ul>
<h3 id="4zabbix-缺点">4、Zabbix 缺点</h3>
<ul>
<li>​    需在被监控主机上安装 agent,所有数据都存在数据库里, 产生的数据据很大,瓶颈主要在数据库。</li>
<li>​    项目批量修改不方便</li>
<li>​     社区虽然成熟，但是中文资料相对较少，服务支持有限；</li>
<li>​     入门容易，能实现基础的监控，但是深层次需求需要非常熟悉Zabbix并进行大量的二次定制开发难度较大</li>
<li>​    系统级别报警设置相对比较多，如果不筛选的话报警邮件会很多；并且自定义的项目报警需要自己设置，过程比较繁琐；</li>
<li>​     缺少数据汇总功能，如无法查看一组服务器平均值，需进行二次开发；</li>
</ul>
<h3 id="5zabbix-监控系统监控对象">5、Zabbix 监控系统监控对象</h3>
<ul>
<li>
<p>数据库：   MySQL,MariaDB,Oracle,SQL Server     agent</p>
</li>
<li>
<p>应用软件：Nginx,Apache,PHP,Tomcat                    agent
-&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;</p>
</li>
<li>
<p>集群：      LVS,Keepalived,HAproxy,RHCS,F5         agent</p>
</li>
<li>
<p>虚拟化：   VMware,KVM,XEN ,docker,k8s              agent</p>
</li>
<li>
<p>操作系统：Linux,Unix,Windows性能参数               agent
-&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;</p>
</li>
<li>
<p>硬件： 服务器，存储，网络设备                              IPMI</p>
</li>
<li>
<p>网络： 网络环境（内网环境，外网环境）              SNMP
-&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="/assets/image-20200408144620616.png">
            <img class="mx-auto" alt="image-20200408144620616" src="/assets/image-20200408144620616.png" />
        </a>
    </p>
<h3 id="6zabbix监控方式">6、Zabbix监控方式</h3>
<h4 id="1被动模式">1、被动模式</h4>
<ul>
<li>被动检测：相对于agent而言；agent, <strong>server向agent请求获取配置的各监控项相关的数据</strong>，agent接收请求、获取数据并响应给server；</li>
</ul>
<h4 id="2主动模式">2、主动模式</h4>
<ul>
<li>
<p>主动检测：相对于agent而言；agent(active),<strong>agent向server请求与自己相关监控项配置</strong>，主动地将server配置的监控项相关的数据发送给server；</p>
</li>
<li>
<p>主动监控能极大节约监控server 的资源。</p>
</li>
</ul>
<h3 id="7zabbix-架构">7、Zabbix 架构</h3>
<p>Zabbix由几个主要的软件组件构成，这些组件的功能如下。</p>
<p>
        <a data-fancybox="gallery" href="assets/111.png">
            <img class="mx-auto" alt="111" src="assets/111.png" />
        </a>
    </p>
<h4 id="1zabbix-server">1、Zabbix Server</h4>
<ul>
<li>Zabbix server 是 agent 程序报告系统可用性、系统完整性和统计数据的核心组件，是所有配置信息、统计信息和操作数据的核心存储器。</li>
</ul>
<h4 id="2zabbix-数据库存储">2、Zabbix 数据库存储</h4>
<ul>
<li>所有配置信息和 Zabbix 收集到的数据都被存储在数据库中。</li>
</ul>
<h4 id="3zabbix-web-界面">3、Zabbix Web 界面</h4>
<ul>
<li>
<p>为了从任何地方和任何平台都可以轻松的访问Zabbix, 我们提供基于Web的Zabbix界面。该界面是Zabbix Server的一部分，通常(但不一定)跟Zabbix Server运行在同一台物理机器上。</p>
</li>
<li>
<p>如果使用 SQLite,Zabbix Web 界面必须要跟Zabbix Server运行在同一台物理机器上。</p>
</li>
</ul>
<h4 id="4zabbix-proxy-代理服务器">4、Zabbix Proxy 代理服务器</h4>
<ul>
<li>Zabbix proxy 可以替Zabbix Server收集性能和可用性数据。Proxy代理服务器是Zabbix软件可选择部署的一部分；当然，Proxy代理服务器可以帮助单台Zabbix Server分担负载压力。</li>
</ul>
<h4 id="5zabbix-agent-监控代理">5、Zabbix Agent 监控代理</h4>
<ul>
<li>Zabbix agents监控代理 部署在监控目标上，能够主动监控本地资源和应用程序，并将收集到的数据报告给Zabbix Server。</li>
</ul>
<h4 id="6zabbix-数据流">6、Zabbix 数据流</h4>
<ul>
<li>
<p>监控方面，为了创建一个监控项(item)用于采集数据，必须先创建一个主机（host）。</p>
</li>
<li>
<p>告警方面，在监控项里创建触发器（trigger），通过触发器（trigger）来触发告警动作（action）。 因此，如果你想收到Server XCPU负载过高的告警，必须满足</p>
</li>
</ul>
<p>​      1、为Server X创建一个host并关联一个用于对CPU进行监控的监控项（Item）。</p>
<p>​      2、创建一个Trigger，设置成当CPU负载过高时会触发</p>
<p>​      3、Trigger被触发，发送告警邮件</p>
<p>虽然看起来有很多步骤，但是使用模板的话操作起来其实很简单，Zabbix 这样的设计使得配置机制非常灵活易用。</p>
<h3 id="8zabbix-常用术语的含义">8、Zabbix 常用术语的含义</h3>
<p>
        <a data-fancybox="gallery" href="/assets/image-20200408144725253.png">
            <img class="mx-auto" alt="image-20200408144725253" src="/assets/image-20200408144725253.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="/assets/image-20200408144903103.png">
            <img class="mx-auto" alt="image-20200408144903103" src="/assets/image-20200408144903103.png" />
        </a>
    </p>
<h4 id="1主机-host">1、主机 (host)</h4>
<ul>
<li>一台你想监控的网络设备，用IP或域名表示</li>
</ul>
<h4 id="2主机组-host-group">2、主机组 (host group)</h4>
<ul>
<li>主机的逻辑组；它包含主机和模板。一个主机组里的主机和模板之间并没有任何直接的关联。通常在给不同用户组的主机分配权限时候使用主机组。</li>
</ul>
<h4 id="3监控项-item">3、监控项 (item)</h4>
<ul>
<li>你想要接收的主机的特定数据，一个度量数据。</li>
</ul>
<h4 id="4触发器-trigger">4、触发器 (trigger)</h4>
<ul>
<li>一个被用于定义问题阈值和“评估”监控项接收到的数据的逻辑表达式
当接收到的数据高于阈值时，触发器从“OK”变成“Problem”状态。当接收到的数据低于阈值时，触发器保留/返回一个“OK”的状态。</li>
</ul>
<h4 id="5事件-event">5、事件 (event)</h4>
<ul>
<li>单次发生的需要注意的事情，例如触发器状态改变或发现有监控代理自动注册</li>
</ul>
<h4 id="6异常-problem">6、异常 (problem)</h4>
<ul>
<li>一个处在“异常”状态的触发器</li>
</ul>
<h4 id="7动作-action">7、动作 (action)</h4>
<ul>
<li>一个对事件做出反应的预定义的操作。</li>
<li>一个动作由操作(例如发出通知)和条件(当时操作正在发生)组成</li>
</ul>
<h4 id="8升级-escalation">8、升级 (escalation)</h4>
<ul>
<li>一个在动作内执行操作的自定义场景; 发送通知/执行远程命令的序列</li>
</ul>
<h4 id="9媒介-media">9、媒介 (media)</h4>
<ul>
<li>发送告警通知的手段；告警通知的途径</li>
</ul>
<h4 id="10通知-notification">10、通知 (notification)</h4>
<ul>
<li>利用已选择的媒体途径把跟事件相关的信息发送给用户</li>
</ul>
<h4 id="11远程命令-remote-command">11、远程命令 (remote command)</h4>
<ul>
<li>一个预定义好的，满足一些条件的情况下，可以在被监控主机上自动执行的命令</li>
</ul>
<h4 id="12模版-template">12、模版 (template)</h4>
<ul>
<li>一组可以被应用到一个或多个主机上的实体（监控项，触发器，图形，聚合图形，应用，LLD，Web场景）的集合</li>
<li>模版的任务就是加快对主机监控任务的实施；也可以使监控任务的批量修改更简单。模版是直接关联到每台单独的主机上。</li>
</ul>
<h4 id="13应用-application">13、应用 (application)</h4>
<ul>
<li>一组监控项组成的逻辑分组</li>
</ul>
<h4 id="14web-场景-web-scenario">14、web 场景 (web scenario)</h4>
<ul>
<li>利用一个或多个HTTP请求来检查网站的可用性</li>
</ul>
<h4 id="15前端-frontend">15、前端 (frontend)</h4>
<ul>
<li>Zabbix提供的web界面</li>
</ul>
<h4 id="16zabbix-api">16、Zabbix API</h4>
<ul>
<li>Zabbix API允许你使用JSON RPC协议 <strong>(是一个无状态且轻量级的远程过程调用（RPC）传送协议，其传递内容透过 JSON 为主)</strong> 来创建、更新和获取Zabbix对象（如主机、监控项、图形和其他）信息或者执行任何其他的自定义的任务</li>
</ul>
<h4 id="17zabbix-server">17、Zabbix server</h4>
<ul>
<li>Zabbix软件实现监控的核心程序，主要功能是与Zabbix proxies和Agents进行交互、触发器计算、发送告警通知；并将数据集中保存等</li>
</ul>
<h4 id="18zabbix-agent">18、Zabbix agent</h4>
<ul>
<li>一个部署在监控对象上的，能够主动监控本地资源和应用的程序</li>
<li>Zabbix agent 部署在监控的目标上，主动监测本地的资源和应用(硬件驱动，内存，处理器统计等)。</li>
<li>Zabbix agent收集本地的操作信息并将数据报告给Zabbix server用于进一步处理。一旦出现异常 (比如硬盘空间已满或者有崩溃的服务进程), Zabbix server会主动警告管理员指定机器上的异常。. Zabbix agents 的极端高效缘于它可以利用本地系统调用来完成统计数据的收集。</li>
</ul>
<h4 id="19被动passive和主动active检查">19、被动（passive）和主动（active）检查</h4>
<p>Zabbix agents 可以执行被动和主动两种检查方式</p>
<p>1、被动检查（passive check） 模式中 agent 应答数据请求，Zabbix server（或者proxy）询问agent数据,如CPU 的负载情况，然后 Zabbix agent 回送结果。</p>
<p>2、主动检查（Active checks） 处理过程将相对复杂。 Agent 必须首先从 Zabbix sever 索取监控项列表以进行独立处理，然后周期性地发送新的值给server。</p>
<p>执行被动或主动检查是通过选择相应的监测项目类型来配置的。item type. Zabbix agent 处理监控项类型有 Zabbix agent 和 Zabbix agent (active)。</p>
<h4 id="20zabbix-proxy">20、Zabbix proxy</h4>
<ul>
<li></li>
<li></li>
<li>一个帮助 Zabbix Server 收集数据，分担Zabbix Server的负载的程序</li>
<li>Zabbix Proxy 是一个可以从一个或多个受监控设备收集监控数据，并将信息发送到Zabbix sever的进程，基本上是代表 sever工作的。 所有收集的数据都在本地进行缓存，然后传送到 proxy 所属的 Zabbix sever。</li>
<li>部署 Proxy 是可选的，但是可能非常有益于分散单个 Zabbix sever 的负载。 如果只有 proxy 收集数据，sever上的进程就会减少 CPU 消耗和磁盘 I / O 负载。</li>
<li>Zabbix proxy 是完成远程区域、分支机构、没有本地管理员的网络的集中监控的理想解决方案。</li>
<li>Zabbix proxy需要使用独立的数据库。</li>
</ul>
<h2 id="四zabbix-监控系统部署">四、Zabbix 监控系统部署</h2>
<h3 id="1实验准备">1、实验准备</h3>
<p>　　centos7.5 系统服务器3台、 一台作为监控服务器， 两台台作为被监控节点， 配置好yum源、 防火墙关闭、 各节点时钟服务同步、 各节点之间可以通过主机名互相通信。</p>
<h4 id="1所有机器关闭防火墙和-selinux">1、所有机器关闭防火墙和 selinux</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># setenforce 0 （修改配置文件关闭）</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># sed -i &#39;s/SELINUX=enforcing/SELINUX=disabled/&#39; /etc/selinux/config </span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl stop firewalld.service</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="2实验服务器配置">2、实验服务器配置</h4>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202115141620-413101680.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202115141620-413101680.png" />
        </a>
    </p>
<h3 id="2zabbix的安装">2、Zabbix的安装</h3>
<h4 id="1更新-yum-仓库">1、更新 yum 仓库</h4>
<h5 id="1下载-yum-仓库">1、下载 yum 仓库</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum -y install wget</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm</span>

<span style="color:#998;font-style:italic"># 安装zabbix源（官方）</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># rpm -ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm</span>
</code></pre></td></tr></table>
</div>
</div><h5 id="2安装-yum-仓库">2、安装 yum 仓库</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#998;font-style:italic"># 配置阿里云</span>
<span style="color:#998;font-style:italic"># 下载 zabbix-release-4.2-1.el7.noarch.rpm</span>
wget https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm

<span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># rpm -ivh zabbix-release-4.2-1.el7.noarch.rpm</span>
</code></pre></td></tr></table>
</div>
</div><h5 id="3更新-yum-仓库">3、更新 yum 仓库</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">8
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">CentOS <span style="color:#099">7</span>

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

<span style="color:#998;font-style:italic">#  运行 yum makecache 生成缓存</span>
</code></pre></td></tr></table>
</div>
</div><div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum repolist </span>
Loaded plugins: fastestmirror, langpacks  
Loading mirror speeds from cached hostfile
zabbix-non-supported                                                      4/4
repo id                     repo name                                   status
base                        base                                         9,363
epel                        epel                                        11,349
zabbix/x86_64               Zabbix Official Repository - x86_64             <span style="color:#099">80</span>
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported -       <span style="color:#099">4</span>
repolist: 20,796
</code></pre></td></tr></table>
</div>
</div><h5 id="4安装-zabbix">4、安装 Zabbix</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum -y install epel-release.noarch</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum -y install zabbix-agent zabbix-get zabbix-sender zabbix-server-mysql zabbix-web zabbix-web-mysql</span>
或者（官方）
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum-config-manager --enable rhel-7-server-optional-rpms</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="2安装设置数据库">2）安装设置数据库：</h4>
<h5 id="1创建-mariadbrepo">1、创建 mariadb.repo</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/yum.repos.d/mariadb.repo</span>
写入以下内容：
<span style="color:#000;font-weight:bold">[</span>mariadb<span style="color:#000;font-weight:bold">]</span>
<span style="color:#008080">name</span> <span style="color:#000;font-weight:bold">=</span> MariaDB 
<span style="color:#008080">baseurl</span> <span style="color:#000;font-weight:bold">=</span> https://mirrors.ustc.edu.cn/mariadb/yum/10.4/centos7-amd64 
<span style="color:#008080">gpgkey</span><span style="color:#000;font-weight:bold">=</span>https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB 
<span style="color:#008080">gpgcheck</span><span style="color:#000;font-weight:bold">=</span><span style="color:#099">1</span>
</code></pre></td></tr></table>
</div>
</div><h5 id="2yum-安装最新版本-mariadb">2、yum 安装最新版本 mariadb</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum install -y MariaDB-server MariaDB-client</span>
</code></pre></td></tr></table>
</div>
</div><h5 id="3修改配置文件">3、修改配置文件</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/my.cnf.d/server.cnf</span>
    <span style="color:#000;font-weight:bold">[</span>mysqld<span style="color:#000;font-weight:bold">]</span>
    <span style="color:#008080">skip_name_resolve</span> <span style="color:#000;font-weight:bold">=</span> ON          <span style="color:#998;font-style:italic"># 跳过主机名解析</span>
    <span style="color:#008080">innodb_file_per_table</span> <span style="color:#000;font-weight:bold">=</span> ON      <span style="color:#998;font-style:italic"># 开启独立表空间</span>
    <span style="color:#008080">innodb_buffer_pool_size</span> <span style="color:#000;font-weight:bold">=</span> 256M  <span style="color:#998;font-style:italic"># 缓存池大小</span>
    <span style="color:#008080">max_connections</span> <span style="color:#000;font-weight:bold">=</span> <span style="color:#099">2000</span>          <span style="color:#998;font-style:italic"># 最大连接数</span>
    log-bin <span style="color:#000;font-weight:bold">=</span> master-log            <span style="color:#998;font-style:italic"># 开启二进制日志</span>
</code></pre></td></tr></table>
</div>
</div><p>4、重启数据库服务</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@localhost ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl enable mariadb</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl restart mariadb</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># mysql_secure_installation  # 初始化mariadb</span>
</code></pre></td></tr></table>
</div>
</div><p>5、创建数据库并授权账号</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">MariaDB <span style="color:#000;font-weight:bold">[(</span>none<span style="color:#000;font-weight:bold">)]</span>&gt; create database zabbix character <span style="color:#0086b3">set</span> <span style="color:#d14">&#39;utf8&#39;</span>;  <span style="color:#998;font-style:italic"># 创建zabbix数据库</span>
MariaDB <span style="color:#000;font-weight:bold">[(</span>none<span style="color:#000;font-weight:bold">)]</span>&gt; grant all on zabbix.* to <span style="color:#d14">&#39;zbxuser&#39;</span>@<span style="color:#d14">&#39;192.168.37.%&#39;</span> identified by <span style="color:#d14">&#39;keer&#39;</span>;										<span style="color:#998;font-style:italic"># 注意授权网段</span>
MariaDB <span style="color:#000;font-weight:bold">[(</span>none<span style="color:#000;font-weight:bold">)]</span>&gt; flush privileges;           <span style="color:#998;font-style:italic"># 刷新授权</span>
</code></pre></td></tr></table>
</div>
</div><p>6、导入 Zabbix 服务表
查看 zabbix-server-mysql 这个包提供了什么</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># rpm -ql zabbix-server-mysql</span>
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.2.6
/usr/share/doc/zabbix-server-mysql-3.2.6/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.2.6/COPYING
/usr/share/doc/zabbix-server-mysql-3.2.6/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.2.6/NEWS
/usr/share/doc/zabbix-server-mysql-3.2.6/README
/usr/share/doc/zabbix-server-mysql-3.2.6/create.sql.gz      <span style="color:#998;font-style:italic"># 生成表的各种脚本</span>
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix
</code></pre></td></tr></table>
</div>
</div><p>使用 create.sql.gz 生成所需要的表</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># gzip -d create.sql.gz</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># head  create.sql           #查看一下表头</span>
CREATE TABLE <span style="color:#d14">`</span>users<span style="color:#d14">`</span> <span style="color:#000;font-weight:bold">(</span>
    <span style="color:#d14">`</span>userid<span style="color:#d14">`</span>                 bigint unsigned                           NOT NULL,
    <span style="color:#d14">`</span><span style="color:#0086b3">alias</span><span style="color:#d14">`</span>                  varchar<span style="color:#000;font-weight:bold">(</span>100<span style="color:#000;font-weight:bold">)</span>    DEFAULT <span style="color:#d14">&#39;&#39;</span>                NOT NULL,
    <span style="color:#d14">`</span>name<span style="color:#d14">`</span>                   varchar<span style="color:#000;font-weight:bold">(</span>100<span style="color:#000;font-weight:bold">)</span>    DEFAULT <span style="color:#d14">&#39;&#39;</span>                NOT NULL,
    <span style="color:#d14">`</span>surname<span style="color:#d14">`</span>                varchar<span style="color:#000;font-weight:bold">(</span>100<span style="color:#000;font-weight:bold">)</span>    DEFAULT <span style="color:#d14">&#39;&#39;</span>                NOT NULL,
    <span style="color:#d14">`</span>passwd<span style="color:#d14">`</span>                 char<span style="color:#000;font-weight:bold">(</span>32<span style="color:#000;font-weight:bold">)</span>        DEFAULT <span style="color:#d14">&#39;&#39;</span>                NOT NULL,
    <span style="color:#d14">`</span>url<span style="color:#d14">`</span>                    varchar<span style="color:#000;font-weight:bold">(</span>255<span style="color:#000;font-weight:bold">)</span>    DEFAULT <span style="color:#d14">&#39;&#39;</span>                NOT NULL,
    <span style="color:#d14">`</span>autologin<span style="color:#d14">`</span>              integer         DEFAULT <span style="color:#d14">&#39;0&#39;</span>               NOT NULL,
    <span style="color:#d14">`</span>autologout<span style="color:#d14">`</span>             integer         DEFAULT <span style="color:#d14">&#39;900&#39;</span>             NOT NULL,
    <span style="color:#d14">`</span>lang<span style="color:#d14">`</span>                   varchar<span style="color:#000;font-weight:bold">(</span>5<span style="color:#000;font-weight:bold">)</span>      DEFAULT <span style="color:#d14">&#39;en_GB&#39;</span>           NOT NULL,
</code></pre></td></tr></table>
</div>
</div><p>查看表头发现没有创建数据库的命令，这正是手动创建数据库的原因。把所需表导入数据库即可：</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># mysql -uzbxuser -h192.168.37.111 -p zabbix &lt; create.sql </span>
Enter password:
</code></pre></td></tr></table>
</div>
</div><p>导入以后，我们进去数据库查看一下：</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">19
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">20
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">21
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">22
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">23
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># mysql -uzbxuser -h192.168.37.111 -p</span>
Enter password:
MariaDB <span style="color:#000;font-weight:bold">[(</span>none<span style="color:#000;font-weight:bold">)]</span>&gt; show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| zabbix             |
+--------------------+
MariaDB <span style="color:#000;font-weight:bold">[(</span>none<span style="color:#000;font-weight:bold">)]</span>&gt; use zabbix;
Database changed
MariaDB <span style="color:#000;font-weight:bold">[</span>zabbix<span style="color:#000;font-weight:bold">]</span>&gt; show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
……
| usrgrp                     |
| valuemaps                  |
+----------------------------+
<span style="color:#099">127</span> rows in <span style="color:#0086b3">set</span> <span style="color:#000;font-weight:bold">(</span>0.00 sec<span style="color:#000;font-weight:bold">)</span>
</code></pre></td></tr></table>
</div>
</div><p>可以看出来，我们的数据已经导入成功了。172..</p>
<h3 id="3配置-server-端">3、配置 server 端</h3>
<p>数据库准备好了以后，我们要去修改 server 端的配置文件。</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">8
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cd /etc/zabbix/</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ls</span>
web  zabbix_agentd.conf  zabbix_agentd.d  zabbix_server.conf
<span style="color:#998;font-style:italic">#为了方便我们以后恢复，我们把配置文件备份一下</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cp zabbix_server.conf{,.bak}</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim zabbix_server.conf</span>
<span style="color:#008080">ListenPort</span><span style="color:#000;font-weight:bold">=</span><span style="color:#099">10051</span>            <span style="color:#998;font-style:italic"># 默认监听端口</span>
<span style="color:#008080">SourceIP</span><span style="color:#000;font-weight:bold">=</span>192.168.37.111     <span style="color:#998;font-style:italic"># 发采样数据请求的 IP</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="1zabbix-日志">1、Zabbix 日志</h4>
<ul>
<li>默认用文件记录，也可以发送给我们的 rsyslog 日志记录系统，如果我们选择默认，则日志存放在 LogFile=/var/log/zabbix/zabbix_server.log 中，也可以自己设置。</li>
</ul>
<h4 id="2日志的滚动">2、日志的滚动</h4>
<ul>
<li>默认值为1，表示滚动。我们设为0则表示不滚动。当数据特别多的时候，我们也可以设置成为1，然后在 Maximum size of log file in MB 设置当数据文件最大到多少时会自动滚动。</li>
</ul>
<p>​                                                                                  
        <a data-fancybox="gallery" href="assets/1204916-20171202111457261-900254693.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111457261-900254693.png" />
        </a>
    </p>
<h4 id="3日志的级别">3、日志的级别</h4>
<ul>
<li>一共有6个级别。我们可以根据自己的需要来设置级别。其中0表示输出最少的信息，5表示输出最详细的信息，默认值为3，设置为3的话就表示，0、1、2、3四个级别都显示。考虑到生产系统中的压力时，这里的信息，如果没有必要的话，越简单越好，只要在出错的时候，我们可以依据其进行排错即可。</li>
</ul>
<p>​                                       
        <a data-fancybox="gallery" href="assets/1204916-20171202111508870-541941322.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111508870-541941322.png" />
        </a>
    </p>
<h4 id="4数据库相关的设置">4、数据库相关的设置</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">    <span style="color:#008080">DBHost</span><span style="color:#000;font-weight:bold">=</span>192.168.37.111       <span style="color:#998;font-style:italic">#数据库对外的主机</span>
    <span style="color:#008080">DBName</span><span style="color:#000;font-weight:bold">=</span>zabbix               <span style="color:#998;font-style:italic">#数据库名称</span>
    <span style="color:#008080">DBUser</span><span style="color:#000;font-weight:bold">=</span>zbxuser              <span style="color:#998;font-style:italic">#数据库用户</span>
    <span style="color:#008080">DBPassword</span><span style="color:#000;font-weight:bold">=</span>keer             <span style="color:#998;font-style:italic">#数据库密码</span>
    <span style="color:#008080">DBPort</span><span style="color:#000;font-weight:bold">=</span><span style="color:#099">3306</span>                 <span style="color:#998;font-style:italic">#数据库启动端口</span>
</code></pre></td></tr></table>
</div>
</div><blockquote>
<p><strong>补充</strong>：</p>
<p>1、使用 grep -i &ldquo;^####&rdquo; zabbix_server.conf  来查看配置文件中有哪些大段</p>
<p>2、使用 grep -i &ldquo;^###&rdquo; zabbix_server.conf 来查看配置文件中每一段中的配置项有哪些</p>
</blockquote>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">
</code></pre></td></tr></table>
</div>
</div><h4 id="5启动服务">5、启动服务</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@server zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl start zabbix-server.service</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="6确认服务端口开启">6、确认服务端口开启</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@server zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ss -nutl |grep 10051</span>
tcp    LISTEN     <span style="color:#099">0</span>      <span style="color:#099">128</span>       *:10051                 *:*                  
tcp    LISTEN     <span style="color:#099">0</span>      <span style="color:#099">128</span>      :::10051                :::*    
</code></pre></td></tr></table>
</div>
</div><h3 id="4配置-web-gui">4、配置 web GUI</h3>
<h4 id="1查找-web-gui-的配置文件">　1、查找 web GUI 的配置文件</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># rpm -ql zabbix-web | less</span>
/etc/httpd/conf.d/zabbix.conf
/etc/zabbix/web
/etc/zabbix/web/maintenance.inc.php
/etc/zabbix/web/zabbix.conf.php
/usr/share/doc/zabbix-web-3.2.6
/usr/share/doc/zabbix-web-3.2.6/AUTHORS
/usr/share/doc/zabbix-web-3.2.6/COPYING
/usr/share/doc/zabbix-web-3.2.6/ChangeLog
/usr/share/doc/zabbix-web-3.2.6/NEWS
/usr/share/doc/zabbix-web-3.2.6/README
……
</code></pre></td></tr></table>
</div>
</div><h4 id="2编辑配置文件">2、编辑配置文件</h4>
<ul>
<li>/etc/httpd/conf.d/zabbix.conf 文件，这个配置文件就是做映射的文件</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">Alias /zabbix /usr/share/zabbix     <span style="color:#998;font-style:italic"># 访问的时候要在主机后加上/zabbix来访问服务</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111541714-86449116.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111541714-86449116.png" />
        </a>
    </p>
<p>注意： 时区是一定要设置的，这里被注释掉是因为，在 php 的配置文件中设置时区，如果在php配置文件中设置时区，则对所有的 php 服务均有效，如果在 zabbix.conf 中设置时区，则仅对zabbix服务有效。所以，在 php 配置文件中设置时区：</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/php.ini</span>
    <span style="color:#000;font-weight:bold">[</span>Date<span style="color:#000;font-weight:bold">]</span>
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    date.timezone <span style="color:#000;font-weight:bold">=</span> Asia/Shanghai
</code></pre></td></tr></table>
</div>
</div><h4 id="3启动-httpd-服务">3、启动 httpd 服务</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl enable httpd</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl start httpd</span>
</code></pre></td></tr></table>
</div>
</div><h3 id="5浏览器访问并进行初始化设置">5、浏览器访问并进行初始化设置</h3>
<p>浏览器访问http://192.168.37.111/zabbix，第一次访问时需要进行一些初始化的设置，按照提示操作：</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111624526-738200150.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111624526-738200150.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111632386-1721515434.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111632386-1721515434.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111651776-1822649685.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111651776-1822649685.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111657823-1996546273.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111657823-1996546273.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111703448-1933168823.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111703448-1933168823.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111709776-2083342842.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111709776-2083342842.png" />
        </a>
    </p>
<ul>
<li>点击Finish以后，跳转到登录页面，使用账号密码登录即可：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111720948-950069230.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111720948-950069230.png" />
        </a>
    </p>
<ul>
<li>默认用户名为：Admin ，密码为：zabbix ，登录后进入仪表盘：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111726964-1900127962.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111726964-1900127962.png" />
        </a>
    </p>
<h3 id="6配置-agent-端">6、配置 agent 端</h3>
<ul>
<li>在被监控的主机安装好agent，设置好 server，并添加到 server 端，将其纳入监控系统中。</li>
</ul>
<h4 id="1安装-zabbix-安装源">1、安装 zabbix 安装源</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># wget https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm</span>
<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># rpm -ivh zabbix-release-4.2-1.el7.noarch.rpm </span>
<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum -y install epel-release.noarch</span>
<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum install zabbix-agent zabbix-sender -y</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="2修改配置文件">2、修改配置文件</h4>
<h4 id="1确认配置文件">1、确认配置文件</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># rpm -ql zabbix-agent </span>
/etc/logrotate.d/zabbix-agent
/etc/zabbix/zabbix_agentd.conf
/etc/zabbix/zabbix_agentd.d
/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
/usr/lib/systemd/system/zabbix-agent.service
/usr/lib/tmpfiles.d/zabbix-agent.conf
/usr/sbin/zabbix_agentd
/usr/share/doc/zabbix-agent-3.4.4
/usr/share/doc/zabbix-agent-3.4.4/AUTHORS
/usr/share/doc/zabbix-agent-3.4.4/COPYING
/usr/share/doc/zabbix-agent-3.4.4/ChangeLog
/usr/share/doc/zabbix-agent-3.4.4/NEWS
/usr/share/doc/zabbix-agent-3.4.4/README
/usr/share/man/man8/zabbix_agentd.8.gz
/var/log/zabbix
/var/run/zabbix
</code></pre></td></tr></table>
</div>
</div><h4 id="2编辑配置文件-1">2、编辑配置文件</h4>
<p>对配置文件做一个备份，然后修改配置文件</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cd /etc/zabbix/</span>
<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cd /etc/zabbix/</span>
<span style="color:#000;font-weight:bold">[</span>root@node1 zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ls</span>
zabbix_agentd.conf  zabbix_agentd.d
<span style="color:#000;font-weight:bold">[</span>root@node1 zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cp zabbix_agentd.conf{,.bak}</span>
<span style="color:#000;font-weight:bold">[</span>root@node1 zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim zabbix_agentd.conf</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111757729-865694486.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111757729-865694486.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111803370-1250338239.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111803370-1250338239.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111809401-778949871.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111809401-778949871.png" />
        </a>
    </p>
<ul>
<li>
<p>重点需要修改 GENERAL PARAMETERS 段：</p>
</li>
<li>
<p>是否允许别人执行远程操作命令，默认是禁用的，打开的话会有安全风险。</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111819198-1483932137.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111819198-1483932137.png" />
        </a>
    </p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">7
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#008080">Server</span><span style="color:#000;font-weight:bold">=</span>192.168.37.111       <span style="color:#998;font-style:italic"># 指明服务器是谁的</span>
<span style="color:#008080">ListenPort</span><span style="color:#000;font-weight:bold">=</span><span style="color:#099">10050</span>            <span style="color:#998;font-style:italic"># 自己监听的端口</span>
<span style="color:#008080">ListenIP</span><span style="color:#000;font-weight:bold">=</span>0.0.0.0            <span style="color:#998;font-style:italic"># 自己监听的地址，0.0.0.0表示本机所有地址</span>
<span style="color:#008080">StartAgents</span><span style="color:#000;font-weight:bold">=</span><span style="color:#099">3</span>               <span style="color:#998;font-style:italic"># 优化时使用的</span>

<span style="color:#008080">ServerActive</span><span style="color:#000;font-weight:bold">=</span>192.168.37.111 <span style="color:#998;font-style:italic"># 主动监控时的服务器</span>
<span style="color:#008080">Hostname</span><span style="color:#000;font-weight:bold">=</span>node1.keer.com     <span style="color:#998;font-style:italic"># 自己能被server端识别的名称</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>启动服务</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl start zabbix-agent.service</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>查看端口是否已开启</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 zabbix<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ss -ntul |grep 10050</span>
tcp    LISTEN     <span style="color:#099">0</span>      <span style="color:#099">128</span>       *:10050                 *:*  
</code></pre></td></tr></table>
</div>
</div><ul>
<li>已经开启成功就可以去 server 端添加主机了，其他主机进行同样的操作，唯一不同的就是配置文件中的 Hostname 要设为对应主机名</li>
</ul>
<h3 id="7监控过程详解">7、监控过程详解</h3>
<h4 id="1修改密码及中文版">1、修改密码及中文版</h4>
<h4 id="imgassets1204916-20171202111827354-72951973png">
        <a data-fancybox="gallery" href="assets/1204916-20171202111827354-72951973.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111827354-72951973.png" />
        </a>
    </h4>
<ul>
<li>按如上操作即可，选择中文以后，点击下面的update即可更新成功</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111833495-129008460.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111833495-129008460.png" />
        </a>
    </p>
<ul>
<li>为了安全起见修改密码</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111841370-1797988674.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111841370-1797988674.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111849495-310227466.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111849495-310227466.png" />
        </a>
    </p>
<ul>
<li>修改完成后同样点击更新即可。</li>
</ul>
<h4 id="2创建主机及主机群组">2、创建主机及主机群组</h4>
<p>　　1、定义一个主机群组</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111857464-2124919444.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111857464-2124919444.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111904167-665674482.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111904167-665674482.png" />
        </a>
    </p>
<p>　　2、添加主机</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111913261-73886293.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111913261-73886293.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111919464-1304275424.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111919464-1304275424.png" />
        </a>
    </p>
<ul>
<li>当然，上面有很多选择卡，有一个加密：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111927823-239348334.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111927823-239348334.png" />
        </a>
    </p>
<ul>
<li>设置完成后，点击添加。添加的主机已经出现在列表中</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111934214-484009707.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111934214-484009707.png" />
        </a>
    </p>
<ul>
<li>同样的把node2节点添加进来：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111940964-633207572.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111940964-633207572.png" />
        </a>
    </p>
<h4 id="3监控项-items">3、监控项 (items)</h4>
<h5 id="1-介绍">1、 介绍</h5>
<ul>
<li>
<p>点击  node1 的监控项，即可创建监控项，首先，创建三个应用集：</p>
</li>
<li>
<p>应用集一般配合监控项使用，是多个同类型的监控项的分类目录</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111950198-929031864.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111950198-929031864.png" />
        </a>
    </p>
<ul>
<li>定义监控项</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202111958792-1773568717.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202111958792-1773568717.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112003964-2111199567.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112003964-2111199567.png" />
        </a>
    </p>
<ul>
<li>任何一个被监控项，如果想要能够被监控，一定要在 zabbix-server 端定义了能够连接至 zabbix-agent  端，并且能够通过命令获取信息。或者在 agent  端定义了能够让server 端获取命令。一般都是内建的命令，都对应的有其名字，被我们称之为 key。</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112012245-1626032764.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112012245-1626032764.png" />
        </a>
    </p>
<ul>
<li>关于key值，可以直接在网页上设置(服务器自动执行)，也可以使用命令行命令(手动执行)来获取：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic">#  zabbix_get -s 192.168.37.122 -p 10050 -k &#34;system.cpu.intr&#34;</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>在 agent 端，也可以使用命令来查看 intr 的速率变化：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112020401-1045624944.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112020401-1045624944.png" />
        </a>
    </p>
<ul>
<li>继续配置监控项：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112109354-402789781.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112109354-402789781.png" />
        </a>
    </p>
<h5 id="2定义一个不带参数的监控项">2、定义一个不带参数的监控项</h5>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112123651-287358961.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112123651-287358961.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112129120-1208851776.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112129120-1208851776.png" />
        </a>
    </p>
<ul>
<li>设置完以后，点击更新，即可加入，并会自动跳转至如下页面</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112140370-1431227410.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112140370-1431227410.png" />
        </a>
    </p>
<ul>
<li>定义完成，回到所有主机，等待5秒，可以看到，node1节点后面的选项已经变成绿色：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112146058-529780188.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112146058-529780188.png" />
        </a>
    </p>
<ul>
<li>回到仪表盘，可以看到，监控项有一个处于启用状态：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112155151-1543121497.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112155151-1543121497.png" />
        </a>
    </p>
<ul>
<li>点击最新数据，选择要查看主机，应用一下，就可以看到数据状态：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112203042-1797920804.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112203042-1797920804.png" />
        </a>
    </p>
<ul>
<li>可以看到，还有一个图形页面，点进去则可以看图形的分布：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112209995-1913438877.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112209995-1913438877.png" />
        </a>
    </p>
<ul>
<li>
<p>事实上，需要关注的指标有很多种，一一添加进来即可。</p>
</li>
<li>
<p>以上定义的监控项是很简单的，指定一个<code>key</code>即可，但是有些监控项是带有参数的，这样一来，监控项就有更多的灵活性。接下来，简单说明需要带参数的监控项：</p>
</li>
</ul>
<h5 id="3定义一个带参数的监控项">3、定义一个带参数的监控项</h5>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112221667-2119454107.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112221667-2119454107.png" />
        </a>
    </p>
<ul>
<li>
<p>[] 就是需要参数的意思，里面的值即为参数</p>
</li>
<li>
<p>&lt;&gt; 为不可省略的。</p>
</li>
</ul>
<p>我们就以这个例子来说明：</p>
<ul>
<li>
<p>if  表示是接口名；</p>
</li>
<li>
<p><!-- raw HTML omitted --> 表示是那种模式，包括但不限于：packets(包)、bytes(字节)、errors(错误)、dropped(丢包)、overuns等等（上述内容通过 ifconfig 查看）</p>
</li>
</ul>
<p>　设置一个监控值：</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112520104-1246148929.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112520104-1246148929.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112525495-114362943.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112525495-114362943.png" />
        </a>
    </p>
<ul>
<li>通过命令行来查看：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># zabbix_get -s 192.168.37.122 -p 10050 -k &#34;net.if.in[ens33,packets]&#34;</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>查看网页的显示情况：检测中 &mdash;&gt; 最新数据 &mdash;&gt; Network Interface Stats(图形)</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112536323-416042280.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112536323-416042280.png" />
        </a>
    </p>
<p><strong>中文乱码解决方法</strong></p>
<ul>
<li>Zabbix监控页面中文显示异常，具体为显示为方块，如图所示。</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/7bf0ccac4fd22fc1bc57be405cfbc2c32ee.jpg">
            <img class="mx-auto" alt="中文监控选项乱码" src="assets/7bf0ccac4fd22fc1bc57be405cfbc2c32ee.jpg" />
        </a>
    </p>
<p>1、查找zabbix安装目找到字体具体位置。</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">19
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">20
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">21
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">22
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">23
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">24
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">25
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">26
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#998;font-style:italic">#查找zabbix安装位置</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># whereis zabbix</span>
zabbix: /usr/lib/zabbix /etc/zabbix /usr/share/zabbix
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ls /usr/share/zabbix/</span>
actionconf.php                 app                 charts.php                   hostinventories.php  items.php        report2.php        styles
adm.gui.php                    applications.php    conf                         host_prototypes.php  js               report4.php        sysmap.php
adm.housekeeper.php            audio               conf.import.php              host_screen.php      jsLoader.php     robots.txt         sysmaps.php
adm.iconmapping.php            auditacts.php       correlation.php              hosts.php            jsrpc.php        screenconf.php     templates.php
adm.images.php                 auditlogs.php       discoveryconf.php            httpconf.php         latest.php       screenedit.php     toptriggers.php
adm.macros.php                 browserwarning.php  disc_prototypes.php          httpdetails.php      <span style="color:#0086b3">local</span>            screen.import.php  tr_events.php
adm.other.php                  chart2.php          favicon.ico                  image.php            locale           screens.php        trigger_prototypes.php
adm.regexps.php                chart3.php          fonts                        images               maintenance.php  search.php         triggers.php
adm.triggerdisplayoptions.php  chart4.php          graphs.php                   img                  map.import.php   services.php       usergrps.php
adm.triggerseverities.php      chart5.php          history.php                  imgstore.php         map.php          setup.php          users.php
adm.valuemapping.php           chart6.php          host_discovery.php           include              overview.php     slideconf.php      zabbix.php
adm.workingtime.php            chart7.php          hostgroups.php               index_http.php       profile.php      slides.php
api_jsonrpc.php                chart.php           hostinventoriesoverview.php  index.php            queue.php        srv_status.php
<span style="color:#998;font-style:italic">#字体文件位置</span>
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ls /usr/share/zabbix/fonts/</span>
graphfont.ttf
<span style="color:#000;font-weight:bold">[</span>root@qfedu.com~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cd /usr/share/zabbix/fonts/</span>
<span style="color:#000;font-weight:bold">[</span>root@server fonts<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># pwd</span>
/usr/share/zabbix/fonts
<span style="color:#000;font-weight:bold">[</span>root@server fonts<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ls -l</span>
总用量 <span style="color:#099">0</span>
lrwxrwxrwx. <span style="color:#099">1</span> root root <span style="color:#099">33</span> 3月  <span style="color:#099">25</span> 15:24 graphfont.ttf -&gt; /etc/alternatives/zabbix-web-font
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1250992a96b4ad79a5020b3918747549b8f.jpg">
            <img class="mx-auto" alt="img" src="assets/1250992a96b4ad79a5020b3918747549b8f.jpg" />
        </a>
    </p>
<ul>
<li>采用 winscp/xftp等工具将 Windows 中文字体上传到 /usr/share/zabbix/fonts/ 文件夹。本文中文字体为宋体。字体权限修改后截图如下所示：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/72b7727b21fb1870e1dd26d6fbd8099b705.jpg">
            <img class="mx-auto" alt="上传字体文件" src="assets/72b7727b21fb1870e1dd26d6fbd8099b705.jpg" />
        </a>
    </p>
<ul>
<li>切换至/etc/alternatives 目录查看软链接。</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/dee2148811c81b40bad6cf343b7686c3b35.jpg">
            <img class="mx-auto" alt="字体软连接" src="assets/dee2148811c81b40bad6cf343b7686c3b35.jpg" />
        </a>
    </p>
<ul>
<li>删除旧软链接并新建。也可以修改为其他中文字体，例如仿宋或者微软雅黑。</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#998;font-style:italic"># 删除旧软链接</span>
<span style="color:#000;font-weight:bold">[</span>root@quedu.com fonts<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># rm -f /etc/alternatives/zabbix-web-font</span>
<span style="color:#998;font-style:italic"># 新建软链接</span>
<span style="color:#000;font-weight:bold">[</span>root@quedu.com fonts<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ln -s /usr/share/zabbix/fonts/simsun.ttc  /etc/alternatives/zabbix-web-font</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>刷新浏览器页面即可，如果显示异常，请重新启动 zabbix-server 服务。</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@quedu.com fonts<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl restart zabbix-server</span>
</code></pre></td></tr></table>
</div>
</div><p>正常显示字体如图所示。</p>
<p>
        <a data-fancybox="gallery" href="assets/380e27ff924670f9dd2f65b3582a02374b0.jpg">
            <img class="mx-auto" alt="中文字体显示正常" src="assets/380e27ff924670f9dd2f65b3582a02374b0.jpg" />
        </a>
    </p>
<h5 id="4快速定义类似指标">4、快速定义类似指标</h5>
<ul>
<li>
<p>要定义一个类似的指标，直接选择克隆，然后简单的修改参数即可。</p>
</li>
<li>
<p>就以定义的 net.if.in[ens33,packets] 为例，如果我们想要在定义一个<code>out</code>的进行如下操作即可：</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112547292-1392248898.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112547292-1392248898.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112554167-1900742947.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112554167-1900742947.png" />
        </a>
    </p>
<ul>
<li>如果要以字节为单位需要定义的话，进行同样的操作：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112605448-457365913.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112605448-457365913.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112611011-1588882925.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112611011-1588882925.png" />
        </a>
    </p>
<ul>
<li>
<p>如果有需要的话也可以把 byte 再克隆成out。</p>
</li>
<li>
<p>可以看一下，已经定义的指标：</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112625604-1195492017.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112625604-1195492017.png" />
        </a>
    </p>
<ul>
<li>进入检测中 &mdash;&gt; 最新数据，可以看到，我们定义的监控项都已经有值了：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112635839-992270373.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112635839-992270373.png" />
        </a>
    </p>
<h5 id="5删除监控项">5、删除监控项</h5>
<ul>
<li>如果有一个监控项，用不上了，就可以删除掉。但是如果你直接删除的话，默认数据是会留下的，所以要先清除数据，然后再删除，具体操作步骤如下：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112656808-290199455.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112656808-290199455.png" />
        </a>
    </p>
<h5 id="6监控项存储的值">6、监控项存储的值</h5>
<p>对于监控项存储的值，老一点的版本只有以下三种方式：</p>
<ul>
<li>
<p>As is：  不对数据做任何处理(存储的为原始值)</p>
</li>
<li>
<p>Delta：（simple change)(变化)，本次采样减去前一次采样的值的结果</p>
</li>
<li>
<p>Delta：（speed per second)(速率)，本次采样减去前一次采样的值，再除以经过的时长；</p>
</li>
</ul>
<p>在3.4版本以后有了更多的表现形式：</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112707261-1106041063.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112707261-1106041063.png" />
        </a>
    </p>
<h4 id="4触发器trigger">4、触发器（trigger）</h4>
<h5 id="1简介">1、简介</h5>
<p>当采集的值定义完了以后，就可以来定义触发器了。触发器的定义是：**界定某特定的item采集到的数据的非合理区间或非合理状态。通常为逻辑表达式。**逻辑表达式（阈值）：通常用于定义数据的不合理区间，其结果如下：</p>
<ul>
<li>
<p>OK (不符合条件)：正常状态 &ndash;&gt; 较老的zabbix版本，其为FALSE；</p>
</li>
<li>
<p>PROBLEM(符合条件)：非正常状态 &ndash;&gt; 较老的zabbix版本，其为TRUE；</p>
</li>
</ul>
<p>评定采样数值是否为合理区间的比较稳妥的方法是——根据最后N次的平均值来判定结果；这个最后N次通常有两种定义方式：</p>
<ul>
<li>
<p>最近N分钟所得结果的平均值</p>
</li>
<li>
<p>最近N次所得结果的平均值</p>
</li>
</ul>
<p>触发器存在可调用的函数：</p>
<ul>
<li>
<p>nodata()　　　　#是否采集到数据，采集不到则为异常</p>
</li>
<li>
<p>last()　　　　　   #最近几次</p>
</li>
<li>
<p>date()                    #时间，返回当前的时间，格式YYYYMMDD</p>
</li>
<li>
<p>time()                    #返回当前的时间，HHMMSS格式的当前时间。</p>
</li>
<li>
<p>now()                    #返回距离Epoch(1970年1月1日00:00:00UTC)时间的秒数</p>
</li>
<li>
<p>dayofmonth()      #返回当前是本月的第几天</p>
</li>
</ul>
<p><strong>注：能用数值保存的就不要使用字符串</strong></p>
<h5 id="2触发器表达式">2、触发器表达式</h5>
<p>基本的触发器表达式格式如下所示</p>
<pre><code>{&lt;server&gt;:&lt;key&gt;.&lt;function&gt;(&lt;parameter&gt;)}&lt;operator&gt;&lt;constant&gt;
</code></pre><ul>
<li>server：主机名称；</li>
<li>key：主机上关系的相应监控项的key；</li>
<li>function：评估采集到的数据是否在合理范围内时所使用的函数，其评估过程可以根据采取的数据、当前时间及其它因素进行；</li>
<li>目前触发器所支持的函数有avg、count、change、date、dayofweek、delta、diff、iregexp、last、max、min、nodata、now、sum等</li>
<li>parameter：函数参数；大多数数值函数可以接受秒数为其参数，而如果在数值参数之前使用“#”做为前缀，则表示为最近几次的取值，如sum(300)表示300秒内所有取值之和，而sum(#10)则表示最近10次取值之和；</li>
<li>此外，avg、count、last、min和max还支持使用第二个参数，用于完 成时间限定；例如，max(1h,7d)将返回一周之前的最大值；</li>
<li>表达式所支持的运算符及其功能如下图所示：
　　
        <a data-fancybox="gallery" href="assets/1204916-20171202112728636-256605681.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112728636-256605681.png" />
        </a>
    </li>
</ul>
<h5 id="3定义一个触发器">3、定义一个触发器</h5>
<p>　查看一下 rate of packets(in) 的值，并以其为标准确定我们的非正常的值：</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112737792-579321512.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112737792-579321512.png" />
        </a>
    </p>
<ul>
<li>
<p>图中最大值为74，最小值为4，平均值为24。这样的话，可以定义50以上的都是非正常的值。</p>
</li>
<li>
<p>定义一个触发器：进入：配置 &mdash;&gt; 主机 &mdash;&gt; node1 &mdash;&gt; 触发器 &mdash;&gt; 创建触发器</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112834464-1059691900.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112834464-1059691900.png" />
        </a>
    </p>
<ul>
<li>表达式可以直接点击右侧的添加，然后定义自己所需的内容，即可自动生成：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112841823-1486407594.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112841823-1486407594.png" />
        </a>
    </p>
<ul>
<li>生成完毕后，我们就点击页面下方的添加，即成功定义了一个触发器，同时页面自动跳转：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112850323-852492156.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112850323-852492156.png" />
        </a>
    </p>
<ul>
<li>查看定义了触发器的监控项：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112857776-952646683.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112857776-952646683.png" />
        </a>
    </p>
<ul>
<li>看到里面就有了一根线，就是定义的值，超过线的即为异常状态，看起来非常直观。现在即使超过了这根线，也仅仅会产生一个触发器事件而不会做其他任何事。因此，需要去定义一个动作(action)。</li>
</ul>
<h5 id="4触发器的依赖关系">4、触发器的依赖关系</h5>
<ul>
<li>
<p>触发器彼此之间可能会存在依赖关系的，一旦某一个触发器被触发了，那么依赖这个触发器的其余触发器都不需要再报警。</p>
</li>
<li>
<p>多台主机是通过交换机的网络连接线来实现被监控的。如果交换机出了故障，我们的主机自然也无法继续被监控，如果此时，所有主机统统报警……想想也是一件很可怕的事情。要解决这样的问题，就是定义触发器之间的依赖关系，当交换机挂掉，只有自己报警就可以了，其余的主机就不需要在报警了。<strong>这样，也更易于我们判断真正故障所在。</strong></p>
</li>
<li>
<p><strong>注意</strong>：目前zabbix不能够直接定义主机间的依赖关系，其依赖关系仅能通过触发器来定义。</p>
</li>
<li>
<p>定义一个依赖关系：打开任意一个触发器，上面就有依赖关系，我们进行定义即可：</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112928604-1229834.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112928604-1229834.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112934808-1854595.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112934808-1854595.png" />
        </a>
    </p>
<ul>
<li>由于当前只定义了一个触发器，就不演示了，过程就是这样~添加以后点击更新即可。触发器可以有多级依赖关系，比如我们看下面的例子：</li>
<li>
        <a data-fancybox="gallery" href="assets/1204916-20171202112943901-1385885917.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112943901-1385885917.png" />
        </a>
    </li>
</ul>
<h4 id="5定义动作action">5、定义动作（action）</h4>
<h5 id="1-简介">1、 简介</h5>
<ul>
<li>
<p>需要去基于一个对应的事件为条件来指明该做什么事，一般就是执行远程命令或者发警报。</p>
</li>
<li>
<p>有一个<strong>告警升级</strong>的机制，所以，当发现问题的时候，一般是先执行一个<strong>远程操作命令</strong>，如果能够解决问题，就会发一个恢复操作的讯息给接收人，如果问题依然存在，则会执行<strong>发警报</strong>的操作，一般默认的警报接收人是当前系统中有的 zabbix 用户，所以当有人需要收到警报操作的话，我们则需要把它加入我们的定义之中。</p>
</li>
<li>
<p>每一个用户也应该有一个接收告警信息的方式，即媒介，就像我们接收短信是需要有手机号的一样。</p>
</li>
<li>
<p>每一个监控主机，能够传播告警信息的媒介有很多种，就算我们的每一种大的媒介，能够定义出来的实施媒介也有很多种。而对于一个媒介来说，每一个用户都有一个统一的或者不同的接收告警信息的端点，我们称之为目标地或者目的地。</p>
</li>
</ul>
<p>综上为了能够发告警信息，</p>
<ul>
<li>
<p>第一，我们要事先定义一个媒介，</p>
</li>
<li>
<p>第二，还要定义这个媒介上用户接收消息的端点（当然，在用户上，我们也称之为用户的媒介）。</p>
</li>
</ul>
<p>系统内建的媒介类型：</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112953417-570252961.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112953417-570252961.png" />
        </a>
    </p>
<p>这只是基本的媒介类型，里面还有更多的细分，以 Email为例：</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202112959964-345494716.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202112959964-345494716.png" />
        </a>
    </p>
<p>注意：同一个类型也可以定义多个，以 Email 为例，可以定义一个腾讯的服务器，一个网易的服务器，一个阿里的服务器等等。</p>
<h5 id="2定义一个媒介media">2、定义一个媒介（media）</h5>
<p>以 Email 为例定义一个媒介：</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113015417-958398301.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113015417-958398301.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113021495-491076870.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113021495-491076870.png" />
        </a>
    </p>
<p>定义后更新就可以
媒介定义好了，怎么才能够让用户接收到邮件呢？比如让Admin用户接收邮件，应该怎么操作呢？具体步骤如下</p>
<ul>
<li>
<p>进入 管理 &mdash;&gt; 用户 &mdash;&gt; Admin &mdash;&gt; 报警媒介</p>
</li>
<li>
<p>添加一条进来：</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113030042-693976775.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113030042-693976775.png" />
        </a>
    </p>
<ul>
<li>添加过后是这样的</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113038792-215702532.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113038792-215702532.png" />
        </a>
    </p>
<ul>
<li>更新就可以</li>
</ul>
<p><strong>注意： 一个用户可以添加多个接收的媒介类型。 请使用163/qq邮箱测试</strong></p>
<h5 id="3定义一个动作action">3、定义一个动作（action）</h5>
<p>　动作是在某些特定条件下触发的，比如，某个触发器被触发了，就会触发动作。现在基于redis来定义一个动作。</p>
<ul>
<li>在 agent 端使用 yum 安装一下 redis：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum install redis -y</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>修改配置文件：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/redis.conf </span>
<span style="color:#0086b3">bind</span> 0.0.0.0        <span style="color:#998;font-style:italic">#不做任何认证操作</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>启动服务检查端口：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl start redis</span>
<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ss -nutlp | grep redis</span>
tcp    LISTEN     <span style="color:#099">0</span>      <span style="color:#099">128</span>       *:6379                  *:*                   users:<span style="color:#000;font-weight:bold">((</span><span style="color:#d14">&#34;redis-server&#34;</span>,pid<span style="color:#000;font-weight:bold">=</span>5250,fd<span style="color:#000;font-weight:bold">=</span>4<span style="color:#000;font-weight:bold">))</span>
</code></pre></td></tr></table>
</div>
</div><h6 id="1定义监控项">1、定义监控项</h6>
<ul>
<li>进入 配置 &mdash;&gt; 主机 &mdash;&gt; node1 &mdash;&gt; 监控项（items）&mdash;&gt; 创建监控项</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113104229-190921891.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113104229-190921891.png" />
        </a>
    </p>
<ul>
<li>填写完毕以后点击下方的添加</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113113058-1658955278.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113113058-1658955278.png" />
        </a>
    </p>
<ul>
<li>该监控项已成功添加。</li>
<li>查看值：检测中 &mdash;&gt; 最新数据</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113122433-2129349774.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113122433-2129349774.png" />
        </a>
    </p>
<h6 id="2定义触发器">2、定义触发器</h6>
<ul>
<li>
<p>定义好了监控项以后，定义一个触发器，当服务有问题的时候，才能及时知道：</p>
</li>
<li>
<p>进入 配置 &mdash;&gt; 主机 &mdash;&gt; node1 &mdash;&gt; 触发器（trigger）&mdash;&gt; 创建触发器</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113131761-6927531.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113131761-6927531.png" />
        </a>
    </p>
<ul>
<li>填写完毕以后点击下方的添加。</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113142604-1237551286.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113142604-1237551286.png" />
        </a>
    </p>
<ul>
<li>
<p>该触发器已成功添加</p>
</li>
<li>
<p>查看：监测中 &mdash;&gt; 最新数据</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113150479-1838545643.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113150479-1838545643.png" />
        </a>
    </p>
<ul>
<li>手动关闭 redis 服务来检测一下：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl stop redis.service</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>进入 监测中 &mdash;&gt; 问题</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113158901-587145295.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113158901-587145295.png" />
        </a>
    </p>
<ul>
<li>看到已经显示的是问题了。并且有持续的时间，当服务被打开，会转为已解决状态：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl start redis.service </span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113209698-2146797322.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113209698-2146797322.png" />
        </a>
    </p>
<h6 id="3定义动作action">3、定义动作（action）</h6>
<ul>
<li>进入 配置 &mdash;&gt; 动作 &mdash;&gt; 创建动作（注意选择事件源为触发器）</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113224323-1883182490.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113224323-1883182490.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113232620-704184287.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113232620-704184287.png" />
        </a>
    </p>
<ul>
<li>操作添加：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113245604-1217342753.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113245604-1217342753.png" />
        </a>
    </p>
<p>需要在虚拟机上进行两项操作，</p>
<ul>
<li>
<p>修改 sudo 配置文件使 zabbix 用户能够临时拥有管理员权限；</p>
</li>
<li>
<p>修改 zabbix 配置文件使其允许接收远程命令。</p>
</li>
</ul>
<p>进行如下操作：</p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># visudo          # 相当于“vim /etc/sudoers”</span>
    <span style="color:#998;font-style:italic">## Allow root to run any commands anywhere</span>
    root    <span style="color:#008080">ALL</span><span style="color:#000;font-weight:bold">=(</span>ALL<span style="color:#000;font-weight:bold">)</span>   ALL
    zabbix    <span style="color:#008080">ALL</span><span style="color:#000;font-weight:bold">=(</span>ALL<span style="color:#000;font-weight:bold">)</span>   NOPASSWD: ALL     <span style="color:#998;font-style:italic"># 添加的一行，表示不需要输入密码</span>

<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/zabbix/zabbix_agentd.conf</span>
    <span style="color:#008080">EnableRemoteCommands</span><span style="color:#000;font-weight:bold">=</span><span style="color:#099">1</span>          <span style="color:#998;font-style:italic"># 允许接收远程命令</span>
    <span style="color:#008080">LogRemoteCommands</span><span style="color:#000;font-weight:bold">=</span><span style="color:#099">1</span>             <span style="color:#998;font-style:italic"># 把接收的远程命令记入日志</span>

<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl restart zabbix-agent.service</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>添加了第一步需要做的事情，重启服务，如果重启不成功怎么办呢？就需要来添加第二步：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113256073-936532007.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113256073-936532007.png" />
        </a>
    </p>
<ul>
<li>添加完成以后</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113304573-1567962822.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113304573-1567962822.png" />
        </a>
    </p>
<ul>
<li>操作添加完了，如果服务自动恢复了，可以发送消息来提示：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113312104-1066002380.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113312104-1066002380.png" />
        </a>
    </p>
<ul>
<li>动作设置完毕，可以点击添加了，添加完成会自动跳转至如下页面：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113334386-1664646229.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113334386-1664646229.png" />
        </a>
    </p>
<ul>
<li>可以手动停止服务来进行测试：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl stop redis.service </span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>到问题页面来查看，发现确实有问题，并且已经解决：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113344229-460694111.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113344229-460694111.png" />
        </a>
    </p>
<ul>
<li>server 端查看是否收到邮件</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113351433-1159937452.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113351433-1159937452.png" />
        </a>
    </p>
<ul>
<li>agent 端查看端口是否开启</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl stop redis.service </span>
<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># ss -ntl</span>
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>        *:6379                   *:*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>        *:111                    *:*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">5</span>      192.168.122.1:53                     *:*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>        *:22                     *:*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>    127.0.0.1:631                    *:*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>        *:23000                  *:*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">100</span>    127.0.0.1:25                     *:*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>        *:10050                  *:*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>       :::111                   :::*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>       :::22                    :::*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">128</span>      ::1:631                   :::*                  
LISTEN      <span style="color:#099">0</span>      <span style="color:#099">100</span>      ::1:25                    :::* 
</code></pre></td></tr></table>
</div>
</div><ul>
<li>端口正常开启，动作触发已经完成。</li>
</ul>
<blockquote>
<p>补充：可以使用脚本来发送警报，脚本存放路径在配置文件中可以找到，定义为：AlterScriptsPath=/usr/lib/zabbix/alertscripts</p>
</blockquote>
<ul>
<li>手动修改一下redis服务的监听端口，这样就不能通过重启服务恢复了：</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/redis.conf</span>
    <span style="color:#998;font-style:italic">#port 6379</span>
    port <span style="color:#099">6380</span>               <span style="color:#998;font-style:italic">#注释掉原来的端口，更换为新的端口</span>

<span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl restart redis</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>网页查看状态：进入 监测中 &mdash;&gt; 问题，可以看到是报错的：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113404433-2118773292.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113404433-2118773292.png" />
        </a>
    </p>
<ul>
<li>经过了重启服务以后还是没能把解决问题，就会发邮件告警</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113411542-651613941.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113411542-651613941.png" />
        </a>
    </p>
<ul>
<li>把服务端口改回来，然后重启服务。这样，等到问题自动解决了以后，会再次收到邮件：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113418464-1285901797.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113418464-1285901797.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113423229-1033392033.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113423229-1033392033.png" />
        </a>
    </p>
<ul>
<li>动作设定已经全部测试完成。　</li>
</ul>
<h4 id="6zabbix可视化">6、zabbix可视化</h4>
<h5 id="1-简介-1">1、 简介</h5>
<p>数据日积月累，想要更直观的了解到各项数据的情况，图形无疑是最佳选择。zabbix 提供了众多的可视化工具直观展示，如 graph、screen 及 map 等。前面也看到过一些简单的图形展示。如果想要把多个相关的数据定义在同一张图上去查看，就需要去自定义图形</p>
<h5 id="2自定义图形graphs">2、自定义图形（Graphs）</h5>
<p>自定义图形中可以集中展示多个时间序列的数据流。支持四种不同形式的图形</p>
<ul>
<li>
<p><strong>线状图</strong>(normal)</p>
</li>
<li>
<p><strong>堆叠面积图</strong>(stacked)、</p>
</li>
<li>
<p><strong>饼图</strong>(pie)”</p>
</li>
<li>
<p><strong>分离型饼图</strong>(exploded)</p>
</li>
</ul>
<p>设置过程如下：进入 配置 &mdash;&gt; 主机 &mdash;&gt; node1 &mdash;&gt; 图形，选择右上角创建图形：</p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113435808-1188202230.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113435808-1188202230.png" />
        </a>
    </p>
<ul>
<li>看一看四种状态：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113446229-1783458714.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113446229-1783458714.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113455729-1650294930.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113455729-1650294930.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113508323-296324748.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113508323-296324748.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113518792-1529967613.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113518792-1529967613.png" />
        </a>
    </p>
<ul>
<li>
<p>主机都可以自定义，一般线型是看的最清晰的，通常会使用这个。克隆一个 packets 来更改为 bytes 用同样的，如果想添加别的内容，也都可以添加的。</p>
</li>
<li>
<p>这里添加了三个图形，我们可以在 监测中 &mdash;&gt; 图形 来查看</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113529323-675233317.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113529323-675233317.png" />
        </a>
    </p>
<h5 id="3聚合图形screens">3、聚合图形（Screens）</h5>
<ul>
<li>创建的自定义图形也可以放在一个聚合图里显示，具体的设置方法： 进入 监测中 &mdash;&gt; 聚合图形 &mdash;&gt; 选择右上角创建聚合图形</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113537964-1631571055.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113537964-1631571055.png" />
        </a>
    </p>
<ul>
<li>可以选择分享：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113545823-147916381.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113545823-147916381.png" />
        </a>
    </p>
<ul>
<li>
<p>定义好了添加即可</p>
</li>
<li>
<p>定义完成以后，需要编辑一下，来指定保存哪些图：</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113554464-752616841.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113554464-752616841.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113600370-802418603.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113600370-802418603.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113605354-1914365422.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113605354-1914365422.png" />
        </a>
    </p>
<ul>
<li>依次添加即可，添加完成之后：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113615761-369104752.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113615761-369104752.png" />
        </a>
    </p>
<ul>
<li>因为只有三张图，所以添加的有重复的。</li>
</ul>
<h5 id="4幻灯片演示slide-shows">4、幻灯片演示（Slide shows）</h5>
<ul>
<li>
<p>如果有多个聚合图形想要按顺序展示的话，我们就可以定义一个幻灯片。</p>
</li>
<li>
<p>具体步骤：进入 监测中 &mdash;&gt; 聚合图形 &mdash;&gt; 右上角选择幻灯片演示 &mdash;&gt; 创建幻灯片</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113722761-480111985.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113722761-480111985.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113728479-1024952951.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113728479-1024952951.png" />
        </a>
    </p>
<ul>
<li>打开以后显示的是图片1，5s以后会自动切换为图片2。这样就可以实现幻灯片演示，就不需要去手动切换了。</li>
</ul>
<h5 id="5-定义拓扑图maps">5、 定义拓扑图（Maps）</h5>
<ul>
<li>
<p>在拓扑图中，可以定义成一个复杂的网络连接图，可以使用一台主机来连接另一台主机，这样的话，就可以查看出到底是哪个链接出了问题。</p>
</li>
<li>
<p>进入 监测中 &mdash;&gt; 拓扑图 &mdash;&gt; 所有地图 &mdash;&gt; Local network(默认就有的)</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113737542-556214868.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113737542-556214868.png" />
        </a>
    </p>
<ul>
<li>通过 Ping 和 Traceroute 就可以实验我们上述的功能。</li>
</ul>
<h4 id="7模板">7、模板</h4>
<h5 id="1创建模板">1、创建模板</h5>
<ul>
<li>
<p>每一个主机的监控项都很多，一个一个的添加实在是太头疼了，更何况，可能不止一个主机。可以把一个 redis 的监控项添加进一个模板里，这样更方便于我们以后的添加。</p>
</li>
<li>
<p>具体操作：进入 配置 &mdash;&gt; 模板 &mdash;&gt; 选择右上角创建模板</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113750354-1623976848.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113750354-1623976848.png" />
        </a>
    </p>
<ul>
<li>
<p>填写完以后，点击下方的添加即可。</p>
</li>
<li>
<p>基于组过滤，就能看到定义的模板：</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113804511-1013330801.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113804511-1013330801.png" />
        </a>
    </p>
<ul>
<li>可以向里面添加应用集、监控项、触发器、图形等等，添加完成以后，后期再有主机需要添加就直接套用模板即可。</li>
<li>需要注意的一点是，<strong>现在添加的是模板，所以不会立即采用数据，只有链接到主机上以后，才会真正生效。</strong></li>
</ul>
<h5 id="2模板的导入与导出">2、模板的导入与导出</h5>
<ul>
<li>可以直接导入一个模板，在互联网上可以找到很多，导入的步骤如下：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113819745-1921041608.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113819745-1921041608.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113824698-623720508.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113824698-623720508.png" />
        </a>
    </p>
<ul>
<li>
<p>创建好的模板也可以导出为文件：</p>
</li>
<li>
<p>任意选中一个准备好的模板，然后页面的最下方就有导出按钮：</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113835714-1215549189.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113835714-1215549189.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113840729-2020667526.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113840729-2020667526.png" />
        </a>
    </p>
<ul>
<li>就可以非常方便的进行应用了</li>
</ul>
<h5 id="3模板的应用">3、模板的应用</h5>
<ul>
<li>进入 配置 &mdash;&gt; 主机 &mdash;&gt; node1 &mdash;&gt; 模板，选择要添加的模板了：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113850261-1781138138.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113850261-1781138138.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113858933-353038188.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113858933-353038188.png" />
        </a>
    </p>
<ul>
<li>点击更新了。成功链接至模板，主机数据就会更新了：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113910870-459511423.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113910870-459511423.png" />
        </a>
    </p>
<p><strong>注意：</strong></p>
<ul>
<li>
<p>一个主机可以链接多个模板，但尽量不要让一个指标被采样两次。</p>
</li>
<li>
<p>如果有多个主机，同时这些主机也在一个主机组里，这样的话，只需要在这个主机组里添加模板，就能够让在主机组里的所有主机进行监控</p>
</li>
</ul>
<h5 id="4移除模板链接">4、移除模板链接</h5>
<ul>
<li>
<p>当一个主机的模板不想要用了，可以移除模板链接，</p>
</li>
<li>
<p>具体操作步骤：进入 配置 &mdash;&gt; 主机 &mdash;&gt; node1 &mdash;&gt; 模板，可以把不需要的模板移除：</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113922292-685697244.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113922292-685697244.png" />
        </a>
    </p>
<ul>
<li>删除试试看，移除并清理以后，点击更新。就会自动跳转至如下界面：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113931151-1815278685.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113931151-1815278685.png" />
        </a>
    </p>
<ul>
<li>模板已经被移除</li>
</ul>
<h4 id="8宏macro">8、宏（macro）</h4>
<h5 id="1简介-1">1、简介</h5>
<ul>
<li>
<p>宏是一种抽象(Abstraction)，它根据一系列预定义的规则替换一定的文本模式，而解释器或编译器在遇到宏时会自动进行这一模式替换。类似地，zabbix基于宏保存预设文本模式，并且在调用时将其替换为其中的文本。</p>
</li>
<li>
<p>zabbix有许多内置的宏，如{HOST.NAME}、{HOST.IP}、{TRIGGER.DESCRIPTION}、{TRIGGER.NAME}、{TRIGGER.EVENTS.ACK}等。　　</p>
</li>
<li>
<p>详细信息请参考<a href="https://www.zabbix.com/documentation/2.0/manual/appendix/macros/supported_by_location">官方文档</a>　　</p>
</li>
</ul>
<h5 id="2级别">2、级别</h5>
<p>宏一共有三种级别，分别是全局宏、模板宏、主机宏。不同级别的宏的适用范围也不一样。</p>
<ul>
<li>
<p>全局宏也可以作用于所有的模板宏和主机宏，优先级最低。</p>
</li>
<li>
<p>模板宏则可以作用于所有使用该模板的主机，优先级排在中间。</p>
</li>
<li>
<p>主机宏则只对单个主机有效，优先级最高。</p>
</li>
</ul>
<h5 id="3类型">3、类型</h5>
<ul>
<li>
<p>宏的类型分为系统内建的宏和用户自定义的宏。</p>
</li>
<li>
<p>为了更强的灵活性，zabbix还支持在全局、模板或主机级别使用用户自定义宏(user macro)。</p>
</li>
<li>
<p>系统内建的宏在使用的时候需要<code>{MACRO}</code>的语法格式，用户自定义宏要使用<code>{$MACRO}</code>这种特殊的语法格式。</p>
</li>
<li>
<p>宏可以应用在item keys和descriptions、trigger名称和表达式、主机接口IP/DNS及端口、discovery机制的SNMP协议的相关信息中……</p>
</li>
<li>
<p>宏的名称只能使用<strong>大写字母、数字及下划线</strong>。</p>
</li>
<li>
<p>进一步信息请参考<a href="https://www.zabbix.com/documentation/2.0/manual/appendix/macros/supported_by_location#additional_support_for_user_macros">官方文档</a>。</p>
</li>
</ul>
<h5 id="4定义一个宏">4、定义一个宏</h5>
<p>　　如果想要在监控项(items)上使用宏，就要先去定义一个宏，然后去创建监控项，直接引用定义好的宏即可。具体操作步骤：</p>
<h6 id="1定义全局宏">1、定义全局宏</h6>
<ul>
<li>进入 管理 &mdash;&gt; 一般 &mdash;&gt; 右上角选择宏</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113946011-1443279156.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113946011-1443279156.png" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202113951651-1189531352.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202113951651-1189531352.png" />
        </a>
    </p>
<ul>
<li>全局宏就添加好了</li>
</ul>
<h6 id="2定义监控项调用宏">2、定义监控项，调用宏</h6>
<ul>
<li>进入 配置 &mdash;&gt; 主机 &mdash;&gt; 所有主机 &mdash;&gt; 监控项 &mdash;&gt; 右上角创建监控项</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202114002058-1535509929.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202114002058-1535509929.png" />
        </a>
    </p>
<ul>
<li>填写完成以后，点击添加。看到这个调用宏的监控项已经添加成功：</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202114011401-371254446.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202114011401-371254446.png" />
        </a>
    </p>
<ul>
<li>查看监控项现在的状态：进入 监测中 &mdash;&gt; 最新数据</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202114025964-731346716.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202114025964-731346716.png" />
        </a>
    </p>
<ul>
<li>把服务停掉。就会变成 down 的状态</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl stop redis</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1204916-20171202114036370-1539610385.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202114036370-1539610385.png" />
        </a>
    </p>
<ul>
<li>发现监控项是可以正常使用的。</li>
</ul>
<h6 id="3修改宏">3、修改宏</h6>
<p>如果把 node1 节点上的 redis 服务监听端口手动改掉，定义的监控项就不能正常使用了，这样的话，就需要去修改宏。因为只是个例，所以我们不需要去修改全局宏，只用修改模板宏或者主机宏就可以了。</p>
<p>模板宏和主机宏的不同修改操作：</p>
<ul>
<li><strong>模板宏</strong>：模板宏的修改，配置 &mdash;&gt; 模板 &mdash;&gt; redis stats（相应的模板） &mdash;&gt; 宏</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202114046214-736225671.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202114046214-736225671.png" />
        </a>
    </p>
<ul>
<li>
<p>点击添加就可以了。</p>
</li>
<li>
<p><strong>主机宏</strong>：主机宏的修改，配置 &mdash;&gt; 主机 &mdash;&gt; 所有主机 &mdash;&gt; node1 &mdash;&gt; 宏</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1204916-20171202114054667-621488105.png">
            <img class="mx-auto" alt="img" src="assets/1204916-20171202114054667-621488105.png" />
        </a>
    </p>
<ul>
<li>点击添加就可以了。</li>
</ul>
<h2 id="五zabbix-用户参数">五、Zabbix 用户参数</h2>
<h3 id="1介绍和用法">1、介绍和用法</h3>
<h4 id="1介绍">1、介绍</h4>
<p>自定义用户参数，也就是自定义key，有时可能想要运行一个代理检查，而不是 Zabbix 的预定义，就可以编写一个命令来检索需要的数据，并将其包含在代理配置文件(&ldquo;UserParameter&quot;配置参数)的用户参数中</p>
<h4 id="2用法格式-syntax">2、用法格式 syntax</h4>
<p>UserParameter=<!-- raw HTML omitted -->,<!-- raw HTML omitted --></p>
<ul>
<li>
<p>A user parameter also contains a key　　一个用户参数也包含一个键</p>
</li>
<li>
<p>The key will be necessary when configuring an item 　　在配置监控项时，key是必需的</p>
</li>
<li>
<p>Note: Need to restart the agent 　　注意:需要重新启动 agent 服务</p>
</li>
</ul>
<h3 id="2用法展示">2、用法展示</h3>
<h4 id="1修改-agent-端的配置设置用户参数">1、修改 agent 端的配置，设置用户参数</h4>
<h5 id="1查找的参数的命令">1、查找的参数的命令</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># free | awk &#39;/^Mem/{print $3}&#39;</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226171855010-665295523.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226171855010-665295523.png" />
        </a>
    </p>
<h5 id="2修改配置文件把查找参数的命令设为用户参数">2、修改配置文件，把查找参数的命令设为用户参数</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cd /etc/zabbix/zabbix_agentd.d/</span>
<span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim memory_usage.conf</span>
<span style="color:#008080">UserParameter</span><span style="color:#000;font-weight:bold">=</span>memory.used,free | awk <span style="color:#d14">&#39;/^Mem/{print $3}&#39;</span>
</code></pre></td></tr></table>
</div>
</div><h5 id="3重启agent-服务">3、重启agent 服务</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl restart zabbix-agent.service </span>
</code></pre></td></tr></table>
</div>
</div><h5 id="4在-zabbix-server-端查询">4、在 zabbix-server 端，查询</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># zabbix_get -s 192.168.30.7 -p 10050 -k &#34;memory.used&#34;</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172647557-2133137319.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172647557-2133137319.png" />
        </a>
    </p>
<h5 id="5在监控上设置一个item监控项使用这个用户参数">5、在监控上，设置一个item监控项，使用这个用户参数</h5>
<p>
        <a data-fancybox="gallery" href="https://images2017.cnblogs.com/blog/1216496/201712/1216496-20171226172026041-1695073569.png">
            <img class="mx-auto" alt="img" src="https://images2017.cnblogs.com/blog/1216496/201712/1216496-20171226172026041-1695073569.png" />
        </a>
    </p>
<h5 id="6查询-graph-图形">6、查询 graph 图形</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172026463-839175044.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172026463-839175044.png" />
        </a>
    </p>
<h3 id="3用法升级">3、用法升级</h3>
<h4 id="1修改-agent-端的配置设置用户参数-1">1、修改 agent 端的配置，设置用户参数</h4>
<h5 id="1命令行查询参数的命令">1、命令行查询参数的命令</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172026698-1464978164.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172026698-1464978164.png" />
        </a>
    </p>
<h5 id="2修改配置文件把查找参数的命令设为用户参数-1">2、修改配置文件，把查找参数的命令设为用户参数</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#008080">UserParameter</span><span style="color:#000;font-weight:bold">=</span>memory.stats<span style="color:#000;font-weight:bold">[</span>*<span style="color:#000;font-weight:bold">]</span>,cat /proc/meminfo | awk <span style="color:#d14">&#39;/^$1/{print $$2}&#39;</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>
<p>分析：$$2：表示不是调前边位置参数的$2 ，而是 awk 的参数 $2</p>
</li>
<li>
<p>注意：$1是调用前边的[*]，位置参数，第一个参数</p>
</li>
</ul>
<h4 id="2在zabbix-server-端查询使用这个用户参数的key">2、在zabbix-server 端，查询使用这个用户参数的key</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172026932-1905881550.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172026932-1905881550.png" />
        </a>
    </p>
<h4 id="3在监控上设置一个item监控项使用这个用户参数">3、在监控上，设置一个item监控项，使用这个用户参数</h4>
<h5 id="1添加-memory-total-的-item-监控项使用-memorystatsmemtotal-的用户参数">1、添加 Memory Total 的 item 监控项，使用 <strong>memory.stats[MemTotal]</strong> 的用户参数</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172027260-1446706159.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172027260-1446706159.png" />
        </a>
    </p>
<ul>
<li>在进程中定义倍数，规定单位</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172027729-143163327.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172027729-143163327.png" />
        </a>
    </p>
<h5 id="2clone-克隆-memory-total-创建memory-free-的监控项">2、clone 克隆 Memory Total 创建Memory Free 的监控项</h5>
<p><strong>memory.stats[MemFree]</strong> 用户参数</p>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172028120-539441659.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172028120-539441659.png" />
        </a>
    </p>
<h5 id="3创建-memory-buffers-的-item-监控项使用-memorystatsbuffers-的key">3、创建 Memory Buffers 的 item 监控项，使用 <strong>memory.stats[Buffers]</strong> 的key</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172028448-41169528.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172028448-41169528.png" />
        </a>
    </p>
<h4 id="4上面3个监控项的-graph-图形">4、上面3个监控项的 graph 图形</h4>
<h5 id="1memory-total">1、memory total</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172028745-1274821835.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172028745-1274821835.png" />
        </a>
    </p>
<h5 id="2memory-free">2、memory free</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172029088-1142382464.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172029088-1142382464.png" />
        </a>
    </p>
<h5 id="3buffers">3、buffers</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172029338-158312847.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172029338-158312847.png" />
        </a>
    </p>
<h3 id="4使用用户参数监控-php-fpm-服务的状态">4、使用用户参数监控 php-fpm 服务的状态</h3>
<p>在agent 端：</p>
<h4 id="1下载设置php-fpm">1、下载，设置php-fpm</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum -y install php-fpm</span>
<span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/php-fpm.d/www.conf # 打开php-fpm的状态页面</span>
</code></pre></td></tr></table>
</div>
</div><div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#008080">user</span> <span style="color:#000;font-weight:bold">=</span> nginx
<span style="color:#008080">group</span> <span style="color:#000;font-weight:bold">=</span> nginx
pm.status_path <span style="color:#000;font-weight:bold">=</span> /status    <span style="color:#998;font-style:italic"># php-fpm 的状态监测页面</span>
ping.path <span style="color:#000;font-weight:bold">=</span> /ping           <span style="color:#998;font-style:italic"># ping 接口，存活状态是否ok</span>
ping.response <span style="color:#000;font-weight:bold">=</span> pong        <span style="color:#998;font-style:italic"># 响应内容pong</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="2-开启-php-fpm-服务">2、 开启 php-fpm 服务</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl start php-fpm</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="3设置-nginx-设置代理php和php-fpm的状态页面匹配">3、设置 nginx ，设置代理php，和php-fpm的状态页面匹配</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/nginx/nginx.conf</span>
location ~ <span style="color:#d14">\.</span>php$ <span style="color:#000;font-weight:bold">{</span>
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  <span style="color:#008080">$document_root$fastcgi_script_name</span>;
            include        fastcgi_params;
<span style="color:#000;font-weight:bold">}</span>
location ~* /<span style="color:#000;font-weight:bold">(</span>php-fpm-status|ping<span style="color:#000;font-weight:bold">)</span> <span style="color:#000;font-weight:bold">{</span>
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  <span style="color:#008080">$fastcgi_script_name</span>;
            include        fastcgi_params;

            allow 127.0.0.1;   <span style="color:#998;font-style:italic"># 因为这个页面很重要，所有需加访问控制</span>
            deny all;

            access_log off;    <span style="color:#998;font-style:italic"># 访问这个页面就不用记录日志了</span>
<span style="color:#000;font-weight:bold">}</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="4复制状态信息页面到网站根目录">4、复制状态信息页面到网站根目录</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cp /usr/share/fpm/status.html /usr/share/nginx/html/</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172029791-156116121.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172029791-156116121.png" />
        </a>
    </p>
<h4 id="5开启nginx服务">5、开启nginx服务</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl start nginx</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="6在agent-端设置用户参数">6、在agent 端，设置用户参数</h4>
<h5 id="1查询-curl-192168307php-fpm-status">1、查询 curl 192.168.30.7/php-fpm-status</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172030088-1020205629.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172030088-1020205629.png" />
        </a>
    </p>
<h5 id="2设置">2、设置</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># cd /etc/zabbix/zabbix_agentd.d/</span>
<span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim php_status.conf</span>
<span style="color:#008080">UserParameter</span><span style="color:#000;font-weight:bold">=</span>php-fpm.stats<span style="color:#000;font-weight:bold">[</span><span style="color:#d14">\*</span><span style="color:#000;font-weight:bold">]</span>,curl -s http://127.0.0.1/status | awk <span style="color:#d14">&#39;/^$1/{print $$NF}&#39;</span>
</code></pre></td></tr></table>
</div>
</div><ul>
<li>分析：设置用户参数为php-fpm.stats[*]，$1为第一个参数；$$NF为awk中的参数，倒数第一列</li>
</ul>
<h5 id="3重启服务">3、重启服务</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl restart zabbix-agent</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="4在zabbix-server-端查询使用这个用户参数的key">4、在zabbix-server 端，查询使用这个用户参数的key</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># zabbix_get -s 192.168.30.7 -p 10050 -k &#34;php-fpm.stats[idle]&#34;</span>
<span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># zabbix_get -s 192.168.30.7 -p 10050 -k &#34;php-fpm.stats[active]&#34;</span>
<span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># zabbix_get -s 192.168.30.7 -p 10050 -k &#34;php-fpm.stats[max active]&#34;</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172030323-150229024.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172030323-150229024.png" />
        </a>
    </p>
<h4 id="5创建一个模板在模板上创建4个item监控项使用定义的用户参数">5、创建一个模板，在模板上创建4个item监控项，使用定义的用户参数</h4>
<h5 id="1创建一个模板">1、创建一个模板</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172030682-152674187.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172030682-152674187.png" />
        </a>
    </p>
<h5 id="2在模板上配置-items-监控项使用刚定义的用户参数">2、在模板上配置 items 监控项，使用刚定义的用户参数</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">fpm.stats<span style="color:#000;font-weight:bold">[</span>total processes<span style="color:#000;font-weight:bold">]</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172031120-396201427.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172031120-396201427.png" />
        </a>
    </p>
<h5 id="3再clone克隆几个items监控项">3、再clone克隆几个items监控项</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">fpm.stats<span style="color:#000;font-weight:bold">[</span>active processes<span style="color:#000;font-weight:bold">]</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172031495-1001452204.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172031495-1001452204.png" />
        </a>
    </p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">fpm.stats<span style="color:#000;font-weight:bold">[</span>max active processes<span style="color:#000;font-weight:bold">]</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172031807-398956119.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172031807-398956119.png" />
        </a>
    </p>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"> fpm.stats<span style="color:#000;font-weight:bold">[</span>idle processes<span style="color:#000;font-weight:bold">]</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172032120-165244744.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172032120-165244744.png" />
        </a>
    </p>
<h5 id="6host主机链接模板">6、host主机链接模板</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172032495-2030001112.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172032495-2030001112.png" />
        </a>
    </p>
<h4 id="7查看graph-图形">7、查看graph 图形</h4>
<h5 id="1php-fpm-total-processes">1、php-fpm total processes</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172032760-1387400769.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172032760-1387400769.png" />
        </a>
    </p>
<h5 id="2php-fpm-active-processes">2、php-fpm active processes</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172033276-1849464959.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172033276-1849464959.png" />
        </a>
    </p>
<h5 id="3php-fpm-max-active-processes">3、php-fpm max active processes</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172033573-911796042.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172033573-911796042.png" />
        </a>
    </p>
<h5 id="4php-fpm-idle-processes">4、php-fpm idle processes</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172034198-1450005062.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172034198-1450005062.png" />
        </a>
    </p>
<h4 id="8把模板导出可以给别人使用">8、把模板导出，可以给别人使用</h4>
<h5 id="1导出模板">1、导出模板</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172034682-1229092767.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172034682-1229092767.png" />
        </a>
    </p>
<ul>
<li>最下面有导出</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172035088-116185645.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172035088-116185645.png" />
        </a>
    </p>
<h5 id="2自己定义用户参数的文件也不要忘记导出">2、自己定义用户参数的文件，也不要忘记导出</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@centos7 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># /etc/zabbix/zabbix_agentd.d/php_status.conf </span>
</code></pre></td></tr></table>
</div>
</div><h2 id="六zabbix-网络发现">六、Zabbix 网络发现</h2>
<h3 id="1介绍-1">1、介绍</h3>
<p>网络发现：zabbix server 扫描指定网络范围内的主机；网络发现是zabbix 最具特色的功能之一，它能够根据用户事先定义的规则自动添加监控的主机或服务等</p>
<p>优点：</p>
<ul>
<li>
<p>加快Zabbix部署</p>
</li>
<li>
<p>简化管理</p>
</li>
</ul>
<p>在快速变化的环境中使用Zabbix，而不需要过度管理</p>
<h3 id="2发现方式">2、发现方式</h3>
<ul>
<li>
<p>ip地址范围</p>
</li>
<li>
<p>可用服务（ftp, ssh, http, &hellip;）</p>
</li>
<li>
<p>zabbix_agent的响应</p>
</li>
<li>
<p>snmp_agent的响应</p>
</li>
</ul>
<h3 id="3发现过程">3、发现过程</h3>
<p>网络发现通常包含两个阶段：discovery 发现和 actions 动作</p>
<p>1、discovery</p>
<ul>
<li>
<p>Zabbix定期扫描网络发现规则中定义的IP范围；检查的频率对于每个规则都是可配置的，每个规则都有一组用于为IP范围执行的服务检查</p>
</li>
<li>
<p>由网络发现模块执行的服务和主机(IP)的每个检查都会生成一个发现事件</p>
</li>
<li>
<p>8种响应事件</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172035479-1598541190.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172035479-1598541190.png" />
        </a>
    </p>
<p>2、actions</p>
<p>网络发现中的事件可以触发 action，从而自动执行指定的操作，把 discvery events当作前提条件；</p>
<ul>
<li>
<p>Sending notifications 发送通知</p>
</li>
<li>
<p>Adding/removing hosts 添加/删除主机</p>
</li>
<li>
<p>Enabling/disabling hosts 启用/禁用host</p>
</li>
<li>
<p>Adding hosts to a group 向组中添加主机</p>
</li>
<li>
<p>Removing hosts from a group 移除组中的主机</p>
</li>
<li>
<p>Linking hosts to/unlinking from a template 从模板链接主机或取消链接</p>
</li>
<li>
<p>Executing remote scripts 执行远程脚本</p>
</li>
</ul>
<p>这些事件的配置还可以基于设备的类型、IP 、状态、上线/ 离线等进行配置</p>
<p>3、网络发现：接口添加</p>
<p>网络发现中添加主机时会自动创建 interface 接口</p>
<p>例如：</p>
<ul>
<li>
<p>如果基于SNMP 检测成功，则会创建SNMP 接口</p>
</li>
<li>
<p>如果某服务同时响应给了agent 和SNMP ，则<strong>两种接口都会创建</strong></p>
</li>
<li>
<p>如果同一种发现机制( 如agent) 返回了非惟一数据，则<strong>第一个接口被识别为默认，其它的为额外接口</strong></p>
</li>
<li>
<p>即便是某主机开始时只有agent 接口，后来又通过snmp 发现了它，同样会为其添加额外的snmp 接口</p>
</li>
<li>
<p>不同的主机如果返回了相同的数据，则第一个主机将被添加，余下的主机会被当作第一个主机的额外接口</p>
</li>
</ul>
<h3 id="4配置网络发现-network-discovery">4、配置网络发现 Network discovery</h3>
<h4 id="1准备一台可被扫描发现的主机">1、准备一台可被扫描发现的主机</h4>
<h5 id="1安装-agent-段的包">1、安装 agent 段的包</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># yum -y install zabbix-agent zabbix-sender</span>
</code></pre></td></tr></table>
</div>
</div><h5 id="2设置-agent-配置可以把之前设置好的node1的配置传过来">2、设置 agent 配置，可以把之前设置好的node1的配置传过来</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># vim /etc/zabbix/zabbix_agentd.conf</span>
<span style="color:#008080">Hostname</span><span style="color:#000;font-weight:bold">=</span>node2.qfedu.com <span style="color:#998;font-style:italic">#只需修改hostname</span>
</code></pre></td></tr></table>
</div>
</div><h5 id="3-visudo-修改sudo的配置">3、 visudo 修改sudo的配置</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># visudo</span>
<span style="color:#998;font-style:italic">#Defaults !visiblepw</span>
zabbix <span style="color:#008080">ALL</span><span style="color:#000;font-weight:bold">=(</span>ALL<span style="color:#000;font-weight:bold">)</span> NOPASSWD: ALL
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172036745-511117378.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172036745-511117378.png" />
        </a>
    </p>
<h5 id="4开启服务">4、开启服务</h5>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># systemctl start zabbix-agent</span>
</code></pre></td></tr></table>
</div>
</div><h4 id="2设置自动发现规则-discovery">2、设置自动发现规则 discovery</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172037370-800415726.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172037370-800415726.png" />
        </a>
    </p>
<p>注释：</p>
<h4 id="3key">3、key</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#000;font-weight:bold">[</span>root@node1 ~<span style="color:#000;font-weight:bold">]</span><span style="color:#998;font-style:italic"># zabbix_get -s 192.168.30.2 -p 10050 -k &#34;system.hostname&#34;</span>
</code></pre></td></tr></table>
</div>
</div><p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172037635-349059993.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172037635-349059993.png" />
        </a>
    </p>
<h5 id="2更新间隔">2、更新间隔</h5>
<p>1h就好，不要扫描太过频繁，扫描整个网段，太废资源；这里为了实验，设为1m</p>
<h4 id="4自动发现成功">4、自动发现成功</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172037948-2146168679.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172037948-2146168679.png" />
        </a>
    </p>
<h4 id="5设置自动发现discovery-的动作action">5、设置自动发现discovery 的动作action</h4>
<h5 id="1创建">1、创建</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172038182-11402625.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172038182-11402625.png" />
        </a>
    </p>
<h5 id="2设置action动作">2、设置action动作</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172038541-1323988067.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172038541-1323988067.png" />
        </a>
    </p>
<h6 id="1设置a条件自动发现规则testnet">1、设置A条件，自动发现规则=test.net</h6>
<h6 id="2设置b条件自动发现状态up">2、设置B条件，自动发现状态=up</h6>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172038823-1466028368.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172038823-1466028368.png" />
        </a>
    </p>
<h6 id="3要做什么操作">3、要做什么操作</h6>
<ul>
<li>
<p>添加主机到监控</p>
</li>
<li>
<p>自动链接Template OS Linux 到此host</p>
</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172039213-1479221797.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172039213-1479221797.png" />
        </a>
    </p>
<h5 id="3配置action-完成默认是-disabled-停用的">3、配置action 完成，默认是 disabled 停用的</h5>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172039526-1399823520.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172039526-1399823520.png" />
        </a>
    </p>
<h5 id="4启用动作查看效果">4、启用动作，查看效果</h5>
<p>确实已经生效，添加主机成功，模板链接成功</p>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172039979-1033265636.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172039979-1033265636.png" />
        </a>
    </p>
<h5 id="5如果自己需要添加的主机已经扫描添加完成就可以关闭网络扫描了因为太耗资源">5、如果自己需要添加的主机已经扫描添加完成，就可以关闭网络扫描了，因为太耗资源</h5>
<h2 id="七zabbix-web-监控">七、Zabbix web 监控</h2>
<h3 id="1介绍-2">1、介绍</h3>
<h4 id="1-web-监控">1、 Web 监控</h4>
<p>监控指定的站点的<strong>资源下载速度</strong>，及<strong>页面响应时间</strong>，还有<strong>响应代码</strong>；</p>
<h5 id="1术语">1、术语</h5>
<ul>
<li>
<p>web Scenario： web场景（站点）</p>
</li>
<li>
<p>web page ：web页面，一个场景有多个页面</p>
</li>
<li>
<p>內建key：要测一个页面，要测三个步骤（下边3个內建key）</p>
</li>
</ul>
<h5 id="2内建-key">2、内建 key</h5>
<ul>
<li>
<p>web.test.in[Scenario,Step,bps]：传输速率</p>
</li>
<li>
<p>web.test.time[Scenario,Step]： 响应时长</p>
</li>
<li>
<p>web.test.rspcode[Scenario,Step]：响应码</p>
</li>
</ul>
<h3 id="2创建设置web场景">2、创建设置web场景</h3>
<h4 id="1创建-1">1、创建</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172040229-465393880.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172040229-465393880.png" />
        </a>
    </p>
<h4 id="2配置-web-监测">2、配置 web 监测</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172040588-1557305887.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172040588-1557305887.png" />
        </a>
    </p>
<h5 id="1点击步骤设置-web-page-web-页面">1、点击步骤，设置 web page web 页面</h5>
<h6 id="1设置名为-home-page">1、设置名为 home page</h6>
<p>URL为http://192.168.30.7/index.html 的web页面</p>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172040885-1526168288.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172040885-1526168288.png" />
        </a>
    </p>
<h6 id="2设置名为-fpm-status">2、设置名为 fpm status</h6>
<p>URL为http://192.168.30.7/fpm-status 的web页面</p>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172041291-925383434.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172041291-925383434.png" />
        </a>
    </p>
<h6 id="3设置2个-web-页面成功">3、设置2个 web 页面成功</h6>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172041870-962857372.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172041870-962857372.png" />
        </a>
    </p>
<ul>
<li>如果有特殊认证，也可以添加</li>
</ul>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172042166-1660206125.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172042166-1660206125.png" />
        </a>
    </p>
<h3 id="3查看测试">3、查看测试</h3>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172042510-1962638311.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172042510-1962638311.png" />
        </a>
    </p>
<h2 id="八zabbix-主动被动-监控">八、Zabbix 主动/被动 监控</h2>
<h3 id="1介绍-3">1、介绍</h3>
<ul>
<li>
<p>被动检测：相对于agent而言；agent, <strong>server向agent请求获取配置的各监控项相关的数据</strong>，agent接收请求、获取数据并响应给server；</p>
</li>
<li>
<p>主动检测：相对于agent而言；agent(active),<strong>agent向server请求与自己相关监控项配置</strong>，主动地将server配置的监控项相关的数据发送给server；</p>
</li>
</ul>
<p>主动监控能极大节约监控server 的资源。zabbix_sender 发送数据：实现人工生成数据，发给server端</p>
<ul>
<li>
<p>zabbix server上的某主机上，直接定义Item时随便定义一个不与其它已有key冲突的key即可，即item type为&quot;zabbix trapper&rdquo;；</p>
</li>
<li>
<p>用法选项：</p>
</li>
</ul>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">6
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">zabbix_sender
　　-z zabbix_server_ip
　　-p zabbix_server_port
　　-s zabbix_agent_hostname
　　-k key
　　-o value 值
</code></pre></td></tr></table>
</div>
</div><h3 id="2设置一个通过內建key发送数据的主动监控">2、设置一个通过內建key发送数据的主动监控</h3>
<h4 id="1agent-端所需要基本配置">1、agent 端所需要基本配置</h4>
<div class="highlight"><div style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#008080">ServerActive</span><span style="color:#000;font-weight:bold">=</span>192.168.30.107 <span style="color:#998;font-style:italic"># 给哪个监控server 发送数据</span>
<span style="color:#008080">Hostname</span><span style="color:#000;font-weight:bold">=</span>node1.qfedu.com    <span style="color:#998;font-style:italic"># 自己的主机名，假设主机定死了，不设置下一项</span>
<span style="color:#998;font-style:italic">#HostnameItem=              # 如果自己的主机名易变动，这一项相当于key一样去匹配</span>
</code></pre></td></tr></table>
</div>
</div><p>注意：若后两项同时启用，下边一个选择生效</p>
<h4 id="2设置一个主动监测">2、设置一个主动监测</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172042870-1427172290.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172042870-1427172290.png" />
        </a>
    </p>
<h5 id="1选择进程每秒更改">1、选择进程，每秒更改，</h5>
<p>因为key：system.cpu.switches ：上下文的数量进行切换，它返回一个整数值。为了监控效果，选择下一秒减上一秒的值作为监控</p>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172043120-1810882608.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172043120-1810882608.png" />
        </a>
    </p>
<h4 id="3已经有-graph-图形">3、已经有 graph 图形</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172043526-25418384.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172043526-25418384.png" />
        </a>
    </p>
<h3 id="3设置一个通过命令zabbix_sender发送数据的主动监控">3、设置一个通过命令zabbix_sender发送数据的主动监控</h3>
<h4 id="1配置一个zabbix-traper采集器-的item-监控项">1、配置一个zabbix traper(采集器) 的item 监控项</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172043838-1551635865.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172043838-1551635865.png" />
        </a>
    </p>
<h4 id="2agent-端手动发送数据">2、agent 端手动发送数据</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172044120-1117751325.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172044120-1117751325.png" />
        </a>
    </p>
<h4 id="3监控到数据的变化">3、监控到数据的变化</h4>
<p>
        <a data-fancybox="gallery" href="assets/1216496-20171226172044682-2050320416.png">
            <img class="mx-auto" alt="img" src="assets/1216496-20171226172044682-2050320416.png" />
        </a>
    </p>

        </div>

        


        

<div class="post-archive">
    <h2>See Also</h2>
    <ul class="listing">
        
        <li><a href="/post/Linux-%E8%BF%90%E7%BB%B4%E7%AC%94%E8%AE%B0/Zabbix/%E7%9B%91%E6%8E%A7%E4%B8%AD%E5%BF%83Zabbix%E8%BF%9B%E9%98%B6/">监控中心Zabbix进阶 </a></li>
        
        <li><a href="/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/">Linux 基础配置 </a></li>
        
        <li><a href="/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4-/">Linux 常用命令 </a></li>
        
        <li><a href="/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/Linux%E6%96%87%E4%BB%B6%E7%89%B9%E6%AE%8A%E6%9D%83%E9%99%90SUIDSGID%E4%B8%8ESBIT/">Linux文件特殊权限 </a></li>
        
        <li><a href="/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/Linux-%E7%A3%81%E7%9B%98%E6%8C%82%E8%BD%BD/">Liunx 磁盘分区与文件挂载 </a></li>
        
    </ul>
</div>


        <div class="post-meta meta-tags">
            
            <ul class="clearfix">
                
                <li><a href='/tags/Zabbix'>Zabbix</a></li>
                
            </ul>
            
        </div>
    </article>
    
    

    
    
</div>

                    <footer id="footer">
    <div>
        &copy; 2021 <a href="https://gitmatrix.gitee.io/">matrix By matrix</a>
        
    </div>
    <br />
    
    <div>
        <div class="github-badge">
            <a href="https://gohugo.io/" target="_black" rel="nofollow"><span class="badge-subject">Powered by</span><span class="badge-value bg-blue">Hugo</span></a>
        </div>
        
        <div class="github-badge">
            <a href="https://github.com/flysnow-org/maupassant-hugo" target="_black"><span class="badge-subject">Theme</span><span class="badge-value bg-yellowgreen">Maupassant</span></a>
        </div>
    </div>
</footer>


    
    <script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script><script src="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>

<a id="rocket" href="#top"></a>
<script type="text/javascript" src='/js/totop.js?v=0.0.0' async=""></script>



    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>




    <script src='/js/douban.js'></script>

                </div>

                <div id="secondary">
    <section class="widget">
        <form id="search" action='https://gitmatrix.gitee.io/search/' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
      <input type="hidden" name="sitesearch" value="https://gitmatrix.gitee.io/">
      <button type="submit" class="submit icon-search"></button>
</form>
    </section>
    
    <section class="widget">
        <h3 class="widget-title">最近文章</h3>
<ul class="widget-list">
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/" title="Linux 基础配置 ">Linux 基础配置 </a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4-/" title="Linux 常用命令 ">Linux 常用命令 </a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/Linux%E6%96%87%E4%BB%B6%E7%89%B9%E6%AE%8A%E6%9D%83%E9%99%90SUIDSGID%E4%B8%8ESBIT/" title="Linux文件特殊权限 ">Linux文件特殊权限 </a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/Linux-%E7%A3%81%E7%9B%98%E6%8C%82%E8%BD%BD/" title="Liunx 磁盘分区与文件挂载 ">Liunx 磁盘分区与文件挂载 </a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Mysql-%E6%95%B0%E6%8D%AE%E5%BA%93/my.cnf-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3/" title="my.cnf 配置文件详解">my.cnf 配置文件详解</a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Mysql-%E6%95%B0%E6%8D%AE%E5%BA%93/Mysql-%E6%93%8D%E4%BD%9C/" title="Mysql 基本操作">Mysql 基本操作</a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Mysql-%E6%95%B0%E6%8D%AE%E5%BA%93/Mysql%E4%BD%93%E7%B3%BB%E7%BB%93%E6%9E%84%E7%AE%A1%E7%90%86/" title="Mysql体系结构管理">Mysql体系结构管理</a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/RAID-%E7%A3%81%E7%9B%98%E9%98%B5%E5%88%97/" title="RAID 磁盘阵列配置 ">RAID 磁盘阵列配置 </a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/Linux-%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE/rpm-%E4%B8%8E-yum-/" title="RPM 与 Yum ">RPM 与 Yum </a>
    </li>
    
    <li>
        <a href="https://gitmatrix.gitee.io/post/SSH/SSH-%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/" title="SSH 基本操作">SSH 基本操作</a>
    </li>
    
</ul>
    </section>

    
<section class="widget">
    <h3 class="widget-title" style="color:#6E718A">课程直达</h3>
    <ul class="widget-list">
        
        <li>
            <a href="https://www.bilibili.com/video/BV1nA411h7C9" title="Burpsuite使用教程" target="_blank" style="color:#6E718A">
                
                    <img src="https://gitee.com/gitmatrix/images/raw/master/img/20210116152721.png">
                
            </a>
        </li>
        
        <li>
            <a href="https://www.bilibili.com/video/BV1yf4y1i7Pb?p=1" title="网络安全提升技术与渗透测试原理深度解析" target="_blank" style="color:#6E718A">
                
                    <img src="https://gitee.com/gitmatrix/images/raw/master/img/6f19fe2958f4d3c5edaee825cda334bac074abc8.jpg">
                
            </a>
        </li>
        
    </ul>
</section>


    <section class="widget">
        <h3 class="widget-title"><a href='/categories/'>分类</a></h3>
<ul class="widget-list">
    
    <li><a href="https://gitmatrix.gitee.io/categories/Liunx/">Liunx (6)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/Mysql/">Mysql (3)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/SSH/">SSH (4)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/Test/">Test (1)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/Web-%E5%AE%89%E5%85%A8/">Web 安全 (9)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/web%E5%9F%BA%E7%A1%80/">web基础 (1)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/">信息收集 (10)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/%E5%8D%81%E5%A4%A7%E6%BC%8F%E6%B4%9E/">十大漏洞 (8)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/%E6%95%99%E7%A8%8B/">教程 (1)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/%E7%BD%91%E7%BB%9C%E5%AE%89%E5%85%A8%E6%B3%95/">网络安全法 (1)</a></li>
    
    <li><a href="https://gitmatrix.gitee.io/categories/%E8%BF%90%E7%BB%B4/">运维 (2)</a></li>
    
</ul>
    </section>

    <section class="widget">
        <h3 class="widget-title"><a href='/tags/'>标签</a></h3>
<div class="tagcloud">
    
    <a href="https://gitmatrix.gitee.io/tags/CSRF/">CSRF</a>
    
    <a href="https://gitmatrix.gitee.io/tags/Chrome-Extension/">Chrome Extension</a>
    
    <a href="https://gitmatrix.gitee.io/tags/Chrome%E6%8F%92%E4%BB%B6/">Chrome插件</a>
    
    <a href="https://gitmatrix.gitee.io/tags/Google-hacking/">Google hacking</a>
    
    <a href="https://gitmatrix.gitee.io/tags/JavaScript/">JavaScript</a>
    
    <a href="https://gitmatrix.gitee.io/tags/Linux/">Linux</a>
    
    <a href="https://gitmatrix.gitee.io/tags/Mysql/">Mysql</a>
    
    <a href="https://gitmatrix.gitee.io/tags/Payload/">Payload</a>
    
    <a href="https://gitmatrix.gitee.io/tags/XSS/">XSS</a>
    
    <a href="https://gitmatrix.gitee.io/tags/Zabbix/">Zabbix</a>
    
    <a href="https://gitmatrix.gitee.io/tags/js/">js</a>
    
    <a href="https://gitmatrix.gitee.io/tags/Mysql/">Mysql</a>
    
    <a href="https://gitmatrix.gitee.io/tags/sql/">sql</a>
    
    <a href="https://gitmatrix.gitee.io/tags/ssh/">ssh</a>
    
    <a href="https://gitmatrix.gitee.io/tags/test/">test</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E4%B8%AD%E5%8D%8E%E4%BA%BA%E6%B0%91%E5%85%B1%E5%92%8C%E5%9B%BD%E7%BD%91%E7%BB%9C%E5%AE%89%E5%85%A8%E6%B3%95/">中华人民共和国网络安全法</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E5%9F%BA%E6%9C%AC%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/">基本信息收集</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%8C%87%E7%BA%B9%E8%AF%86%E5%88%AB/">指纹识别</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%94%B6%E9%9B%86%E5%AD%90%E5%9F%9F%E4%BF%A1%E6%81%AF/">收集子域信息</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%94%B6%E9%9B%86%E6%95%8F%E6%84%9F%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6/">收集敏感目录文件</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%94%BB%E5%87%BB/">攻击</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%95%99%E7%A8%8B/">教程</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%95%B4%E7%AB%99%E5%88%86%E6%9E%90/">整站分析</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%96%87%E4%BB%B6/">文件</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E4%BB%8B%E7%BB%8D/">渗透测试介绍</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E6%B5%81%E7%A8%8B/">渗透测试流程</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E6%BC%8F%E6%B4%9E/">漏洞</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E7%9C%9F%E5%AE%9EIP%E5%9C%B0%E5%9D%80%E6%9F%A5%E8%AF%A2/">真实IP地址查询</a>
    
    <a href="https://gitmatrix.gitee.io/tags/%E9%9D%B6%E5%9C%BA/">靶场</a>
    
</div>
    </section>

    
<section class="widget">
    <h3 class="widget-title">友情链接</h3>
    <ul class="widget-list">
        
        <li>
            <a target="_blank" href="https://www.bugbank.cn/" title="漏洞银行">漏洞银行</a>
        </li>
        
        <li>
            <a target="_blank" href="https://www.xf1433.com/59.html" title="电脑黑客书籍在线阅读">电脑黑客书籍在线阅读</a>
        </li>
        
        <li>
            <a target="_blank" href="http://yuedu.baidu.com/ebook/14a722970740be1e640e9a3e" title="Android Gradle权威指南">Android Gradle权威指南</a>
        </li>
        
    </ul>
</section>


    <section class="widget">
        <h3 class="widget-title">其它</h3>
        <ul class="widget-list">
            <li><a href="https://gitmatrix.gitee.io/index.xml"></a></li>
        </ul>
    </section>
</div>
            </div>
        </div>
    </div>
</body>

</html>